首先,当使用
@Input
装饰师,你应该使用
[primaryActionDisabled]
结合
然后你需要传递可观察的,而不是表达式:
// in parent controller
primaryActionDisabled$ = new BehaviorSubject<boolean>(true); // disabled by default
// in parent template
<full-screen-dialog-header
(onClickPrimaryAction)="onClickSaveCustomer()"
[primaryActionDisabled]="primaryActionDisabled$">
</full-screen-dialog-header>
primaryActionDisabled$.next(newBoolValue);
每次值都应该更改(因此每次表达式
customerFormGroup.enabled && !customerFormGroup.valid
最后,在您的子组件中,使用异步管道来处理该可观察值:
<button mat-button
(click)="onClickPrimaryActionEvent($event)"
[disabled]="primaryActionDisabled | async">{{ primaryActionText }}</button>