admin管理员组

文章数量:1640615

Angular 动态属性绑定

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

When the expression resolves to null or undefined, 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();
}

本文标签: 绑定属性动态AngularInput