我有一个数组(数据源)列表,我正在其中执行添加和删除操作。我在子组件中传递了一个数组(dataSource),并在子组件中添加了 *ngFor 循环。我已将数组作为 getter setter 传递以检测 @Input 更改。
这是我的AppComponent:
<div>
<vertital-tabs
[config]="config"
[dataSource]="dataSource" <-- Array changes I want to detect in Child
[(selectedItem)]="selectedItem">
</vertital-tabs>
<div style="background-color: yellow;margin: 10px">
{{ selectedItem | json }}
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在ChildComponent (垂直制表符) 中:
get dataSource(): any {
return this._dataSource;
}
@Input() set dataSource(value: any) {
this._dataSource = value;
// Not called this on Add New button even if Input Datasource is changed.
// I want this to be called on Add New …
Run Code Online (Sandbox Code Playgroud) javascript typescript angular-material angular angular-reactive-forms