элемент списка. html
<nz-list
[nzDataSource]="alerts$ | async"
nzBordered
nzSize="small"
[nzItemLayout]="'horizontal'"
[nzRenderItem]="notif"
[nzBordered]="false"
>
<ng-template #notif let-item>
<nz-list-item [nzContent]="content" (click)="openNotifModal(item)"></nz-list-item>
</ng-template>
list-item.ts
@Select(AlertState.get('books')) alerts$: Observable<Partial<Books>>;
displayAlert$ = new BehaviorSubject(undefined);
openNotifModal(item?: any) {
this.displayAlert$.next(item);
}
messages-modal.ts
@Input()
set onDisplay(data: object) {
if (data) {
this.dataDisplayed = { ...data };
this.openNotifModal();
}
}
notifModal: NzModalRef;
constructor(private modalService: NzModalService ){ }
openNotifModal(): void {
this.notifModal = this.modalService.create({
nzTitle: 'Message Alert',
nzContent: 'This is a message alert'
nzWrapClassName: 'vertical-center-modal dialog-modal',
nzWidth: 400,
nzMaskClosable: false,
nzClosable: false,
nzOnOk: () => console.log('Click ok')
});
}
есть два модуля: list-item
и notificitaion-modal
.
Когда я пытаюсь нажать на модал, это сообщение об ошибке в консоли ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'nzNoAnimation: undefined'. Current value: 'nzNoAnimation: false'. 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 ?
Как это исправить? потому что каждый раз, когда я нажимаю на элемент, появляется ошибка.