这就是我在 View 中渲染 cases
ObservableArray 的方式
<ListView [items]="cases" class="list-group" *ngIf="cases">
<ng-template let-case="item">
假设 cases
具有以下值:
cases = [{id: 1, name: "Sam"}, {id: 2, name: "Romio"}]
当我像这样更新第一个项目时,如何让我的 ListView 重新渲染或以某种方式更新 View ?
案例[0]["name"] = "Michael"
最佳答案
您是否尝试过应用 NgZone 中的更改?我用它来更新数组(不是 ObservableArray),并且相应的 RadListView 自动更新。
this.ngZone.run(() => {
this.dummyService.addFile(this.file).subscribe(
(fileId) => {
this.folder.push(this.file);
},
(error) => {
this handleError(error);
});
});
关于nativescript - 当 ObservableArray 项更改时重新渲染 Nativescript ListView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46692517/