将Angular方法绑定到HTML禁用属性不起作用

时间:2017-07-04 17:57:01

标签: angular

在我的html中,当我进入和分页时,我想制作一个禁用按钮。

<button type="button" [disabled]="disable()">

所以我创建了一个带有方法的服务

public getDisable() {
 const curr = this.getCurrent();
 return ((curr.index + 1) == (this._pages.length)) ? true : false;
}

在文件中,按钮是ts,我注入服务并使用getDisable()在按钮中使用。

public disable() {
 this.MyService.getDisable();
}

我在控制台中放入了每个变量,当我到达数组的末尾时,意味着这个

((curr.index + 1) === (this._pages.length))

为真(在控制台中我得到3 === 3),按钮不会被禁用。

0 个答案:

没有答案