问题描述
我从后端获取数据,需要在表中显示。 数据必须按某些属性分组,这是代码:
getRows(data: MyData[]): Array<Array<MyData>> {
const exceptionsArray: Array<Array<MyData>> = [];
const exceptions = new Map<string,Array<MyData>>();
data.forEach(exc => {
const key = exc.name != null ? exc.name + '_' + exc.id : exc.id;
const exceptionsArray = exceptions.has(key) ? exceptions.get(key) : new Array<MyData>();
exceptionsArray.push(exc);
exceptions.set(key,exceptionsArray);
}
);
exceptions.forEach((value: Array<MyData>) => {
exceptionsSet.push(value);
});
return exceptionsSet;
}
数据插入到表中:
<table width="100%">
<thead>..
<ng-container *ngFor="let row of getData(mpnIpn.data)">
<tr *ngFor="let record of row">
<td class="small text-muted noBg"> </td>
<ng-container *ngIf="allowManipulate; else emptyCells">
<td class="noBg">
<a class="pointer text-Nowrap" title="New comment"
(click)="newComment(record)">New comment</a>
<span *ngIf="row.length > 1">
/ <a class="pointer text-Nowrap" title="Modify records"
(click)="modifyRecords(record)">Modify records</a>
</span>
</td>
</ng-container>
<ng-container #emptyCells>
<td class="noBg"> </td>
</ng-container>
</tr>
</ng-container>
</thead>
当我第一次进入页面并单击链接时,将打开一个模态窗口(可以单击链接)。
但是当我转到包含ng-select的其他页面时,我单击此ng-select并返回带有表格的页面,则无法单击链接。鼠标已更改,但模式窗口未打开。我尝试在单击时打印到控制台,但这也不起作用。
当我按F5
(刷新页面)时,一切开始起作用。我正在使用Angular 5。
谢谢。
已编辑
当我在有角度的版本10中复制此代码时,一切运行正常
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)