Javascript 函数中的角度2父子布尔值
我试图从父组件到子组件发出一个布尔更改,但运气不好 父组件:Javascript 函数中的角度2父子布尔值,javascript,angular,typescript,Javascript,Angular,Typescript,我试图从父组件到子组件发出一个布尔更改,但运气不好 父组件: isActionComplete:布尔型; deleteUser(){ this.userService.delete(); this.isActionComplete=true; 设置超时(()=>{ this.ispopupacative=false; }, 3000); this.isActionComplete=false; } 父html: 子组件: @Input()isActionComplete:boolean;
isActionComplete:布尔型;
deleteUser(){
this.userService.delete();
this.isActionComplete=true;
设置超时(()=>{
this.ispopupacative=false;
}, 3000);
this.isActionComplete=false;
}
父html:
子组件:
@Input()isActionComplete:boolean;
子html:
完成
如果我更改'isActionComplete:boolean;'“isActionComplete=true;”在父组件中,它确实会更改子布尔值的状态,但由于某些原因,当其在“deleteUser”函数中不起作用时
有人能告诉我哪里出了问题吗
感谢Synatx提供的属性绑定是
[prop]=“value”
属性绑定的Synatx是
[prop]=“value”
我意识到我的问题是什么!是设置超时导致了问题。我需要把它移到这里面:
deleteUser() {
this.userService.delete();
this.isActionComplete = true;
setTimeout(() => {
this.isPopUpActive = false;
this.isActionComplete = false;
}, 3000);
}
希望这对将来的人有所帮助 我意识到我的问题是什么!是设置超时导致了问题。我需要把它移到这里面:
deleteUser() {
this.userService.delete();
this.isActionComplete = true;
setTimeout(() => {
this.isPopUpActive = false;
this.isActionComplete = false;
}, 3000);
}
希望这对将来的人有所帮助 哇,反应真快,谢谢!我已将其更改为上述内容,但仍然无法工作。这似乎是因为它在一个函数中。如果我在父函数外更改布尔状态,它会工作哇,这是快速响应,谢谢!我已将其更改为上述内容,但仍然无法工作。这似乎是因为它在一个函数中。如果我在父函数之外更改布尔状态,请单击最有帮助答案左侧的复选标记关闭问题请单击最有帮助答案左侧的复选标记关闭问题
deleteUser() {
this.userService.delete();
this.isActionComplete = true;
setTimeout(() => {
this.isPopUpActive = false;
this.isActionComplete = false;
}, 3000);
}