我有这个
HTML
<div [formGroup]="frmStepTwo" fxLayout="column">
<sfc-account-selector formControlName="account">
</sfc-account-selector>
</div>
TS(查看)
this.frmStepTwo = this._formBuilder.group({
procedure: ["", Validators.required],
account: ["", Validators.required]
});
证监会帐户选择器.html
<div class="sfc-account-selector" [formGroup]="ctrlGroup">
<mat-radio-group
fxLayout="column"
(change)="inputChange($event)"
formControlName="account">
<mat-radio-button [value]="account" *ngFor="let account of accounts">
<div>
<img class="sfc-as-option-icon" [src]="imgBase + account.iconPath"/>
<div class="sfc-as-label">
<span class="sfc-as-name">{{account.serviceName}}</span>
<span class="sfc-as-desc">{{account.serviceDescription}}</span>
</div>
</div>
</mat-radio-button>
</mat-radio-group>
<small *ngIf="required">REQUIRED</small>
</div>
sfc-account-selector是一个自定义表单控件。我面临的问题是,如果我在 getter 上使用required属性<sfc-account-selector>
,setter 将触发。如果我将控件包装在另一个表单控件中,则不会触发 require。
包装在所需的 formControl 中时,有没有办法更新“必需”?