小编Dev*_*tel的帖子

当我将新项目推送到数组中时,未检测到角度输入属性更改

我有一个数组(数据源)列表,我正在其中执行添加和删除操作。我在子组件中传递了一个数组(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

1
推荐指数
1
解决办法
1888
查看次数