如何解决Angular单击ng-select
我从后端获取数据,需要在表中显示。 数据必须按某些属性分组,这是代码:
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。
谢谢。
已编辑
添加了stackblitz
当我在有角度的版本10中复制此代码时,一切运行正常
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。