【发布时间】:2019-11-15 19:04:49
【问题描述】:
有一个奇怪的问题,复选框被加载了 id 和值但没有被点击。也没有显示错误。
<button [popover]="columnConfigJobDetails"><span class="icon-cog"></span></button>
<popover-content #columnConfigJobDetails [closeOnClickOutside]="true">
<ng-container *ngFor='let col of columnDropdownStates'><form>
<label *ngIf='col' class="checkbox ">
<input type="checkbox" id={{col.field}} [checked]="col.visible"
name={{col.header}} (change)="onColumnChange($event)"/>
<span class="checkbox__input"></span>
<span class="checkbox__label">{{col.header}}</span>
</label></form>
</ng-container>
</popover-content>
我的 Angular/typescript 代码看起来像一个对象数组。
this.columnDropdownStates -:
0: {header: "Name", field: "name", visible: true}
1: {header: "Devices Enabled", field: "enabledDeviceNumber", visible: true}
2: {header: "Description", field: "description", visible: true}
新更新 - 我确实收到此错误,但不确定它是什么意思
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngIf: undefined'. Current value: 'ngIf: true'. It seems like the view has been created after its parent and its children have been dirty checked. Has it been created in a change detection hook ?
【问题讨论】:
-
你在使用视图子吗?
-
@AngelaAmarapala 没错。
-
columnDropdownStatesprop 是如何在你的 typescript 文件中创建的?