我有一个带有子组件(模态)的简单组件。
parentComponent.ts
onShowModal($e) {
chrome.runtime.sendMessage(AppConsts.chromeExtension.id, {}, (reply) =>
{
const isInstalled = reply ? true : false; // here is true
this._service.getById(id)
.subscribe(response => {
this.customModal.show($e, response, isInstalled);
});
});
}
customModalComponent.ts
// Component Code
isExtensionInstalled = false;
show(event, response, isInstalled: boolean) {
this.isExtensionInstalled = isInstalled;
this.response = response;
this.event = event;
this.modal.show(); //Here the modal appears on the screen, but the `this.isExtensionInstalled` variable stays as false for a while, then it changes to true (after some milliseconds);
}
问题在于,当我执行onShowModal
方法时,isInstalled
常量为真,因此true
是isInstalled参数。但是当模态实际出现在屏幕上时,isExtensionInstalled
会暂时保持为假,然后它会更改为参数中传递的正确值(true)。
为什么会这样?