1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Angular 动态属性绑定 - disabled input with formControlName

Angular 动态属性绑定 - disabled input with formControlName

时间:2020-09-07 13:14:17

相关推荐

Angular 动态属性绑定 - disabled input with formControlName

Angular 动态属性绑定

<p [attr.attribute-you-are-targeting]="expression"></p>

When the expression resolves tonullorundefined, Angular removes the attribute altogether.

方法1 - html:

<input type="text" formControlName="name" [attr.disabled]="readOnly || null">

方法2 - formGroup:

<input type="text" formControlName="name">if (this.readOnly) {this.formGroup.get('name').disable();}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。