简体   繁体   English

按钮属性绑定“禁用”在角度4中不起作用

[英]button property binding “disable” not working in angular 4

I have created a component name servers. 我已经创建了一个组件名称服务器。 In servers.component.ts i have created a variable name allowServer with bool value false (to disable button in start of the app). 在servers.component.ts中,我创建了一个变量名称allowServer,其布尔值为false(以禁用应用程序启动中的按钮)。 In constructor, I have used javascript setTimeout function to change the value of allowServer to True. 在构造函数中,我使用了JavaScript setTimeout函数将allowServer的值更改为True。 The value is changing but button is not getting enabled 值正在更改,但未启用按钮

servers.component.ts . servers.component.ts

servers.component.html What am i doing wrong?? server.component.html我在做什么错?

You need to use ArrowFunction ()=> to preserve this context within setTimeOut . 您需要使用ArrowFunction()=>以保持在这个范围内setTimeOut

setTimeout(()=>{    
      this.allowServer = true;
 },3000);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM