angular2 中是否有 ng-disabled 的替代方案?
is there any alternative for ng-disabled in angular2?
我正在使用 angular2 进行开发,想知道在 angular2 中是否有 ng-disabled
的替代方案。
例如。
下面的代码在 angularJS:
<button ng-disabled="!nextLibAvailable" ng-click="showNext('library')" class=" btn btn-info btn-xs" title="Next Lib >> {{libraries.name}}">
<i class="fa fa-chevron-right fa-fw"></i>
</button>
只是想知道我怎样才能实现这个功能?
有任何输入吗?
要将 disabled
属性 设置为 true
或 false
使用
<button [disabled]="!nextLibAvailable" (click)="showNext('library')" class=" btn btn-info btn-xs" title="Next Lib"> {{libraries.name}}">
<i class="fa fa-chevron-right fa-fw"></i>
</button>
[attr.disabled]="valid == true ? true : null"
您必须使用 null
从 html 元素中删除属性。
是 你可以设置 [disabled]= "true" 或者如果它是单选按钮或复选框那么你可以简单地使用 disable
对于单选按钮:
<md-radio-button disabled>Select color</md-radio-button>
对于下拉菜单:
<ng-select (selected)="someFunction($event)" [disabled]="true"></ng-select>
对于angular 4+版本你可以试试
<input [readonly]="true" type="date" name="date" />
这是我使用角度 6 的解决方案。
[readonly]="DateRelatedObject.bool_DatesEdit ? true : false"
加上上面给出的答案
[attr.disabled]="valid == true ? true : null"
对我没有用,而且要注意使用 null 因为它期待 bool。
我正在使用 angular2 进行开发,想知道在 angular2 中是否有 ng-disabled
的替代方案。
例如。 下面的代码在 angularJS:
<button ng-disabled="!nextLibAvailable" ng-click="showNext('library')" class=" btn btn-info btn-xs" title="Next Lib >> {{libraries.name}}">
<i class="fa fa-chevron-right fa-fw"></i>
</button>
只是想知道我怎样才能实现这个功能? 有任何输入吗?
要将 disabled
属性 设置为 true
或 false
使用
<button [disabled]="!nextLibAvailable" (click)="showNext('library')" class=" btn btn-info btn-xs" title="Next Lib"> {{libraries.name}}">
<i class="fa fa-chevron-right fa-fw"></i>
</button>
[attr.disabled]="valid == true ? true : null"
您必须使用 null
从 html 元素中删除属性。
是 你可以设置 [disabled]= "true" 或者如果它是单选按钮或复选框那么你可以简单地使用 disable
对于单选按钮:
<md-radio-button disabled>Select color</md-radio-button>
对于下拉菜单:
<ng-select (selected)="someFunction($event)" [disabled]="true"></ng-select>
对于angular 4+版本你可以试试
<input [readonly]="true" type="date" name="date" />
这是我使用角度 6 的解决方案。
[readonly]="DateRelatedObject.bool_DatesEdit ? true : false"
加上上面给出的答案
[attr.disabled]="valid == true ? true : null"
对我没有用,而且要注意使用 null 因为它期待 bool。