有人可以帮助理解我这样做的方式吗?
<app-tests-list
[(ngModel)]="selectedTests"
[(indeterminate)]="globalCheckbox.indeterminate"
[(allSelection)]="globalCheckbox.value"
></app-tests-list>
在子组件中我这样做
@Input('indeterminate') _indeterminate: boolean;
@Output('indeterminate') _indeterminateChange = new EventEmitter<any>();
@Input('allSelection') _allSelection: boolean;
@Output('allSelection') _allSelectionChange = new EventEmitter<any>();
setIndeterminate(value) {
this._indeterminate = value;
this._indeterminateChange.emit(this._indeterminate);
}
setAllSelection(value) {
this._allSelection = value;
this._allSelectionChange.emit(this._allSelection);
}
但是在父组件中,我只能像这样使用它
<app-tests-list
[(ngModel)]="selectedTests"
[indeterminate]="globalCheckbox.indeterminate"
(indeterminate)="globalCheckbox.indeterminate = $event"
[allSelection]="globalCheckbox.value"
(allSelection)="globalCheckbox.value = $event"></app-tests-list>
但它并不像我预期的那么美丽:)