Reputation: 547
This is how I render the cases
ObservableArray in my view
<ListView [items]="cases" class="list-group" *ngIf="cases">
<ng-template let-case="item">
Say cases
has these values:
cases = [{id: 1, name: "Sam"}, {id: 2, name: "Romio"}]
How can I get my ListView to re-render or somehow update the view when I update the first item like this?
cases[0]["name"] = "Michael"
Upvotes: 2
Views: 892
Reputation: 135
Have you tried to do apply the change in NgZone? I used this to update an array (not ObservableArray) and the corresponding RadListView automatically was updating.
this.ngZone.run(() => {
this.dummyService.addFile(this.file).subscribe(
(fileId) => {
this.folder.push(this.file);
},
(error) => {
this handleError(error);
});
});
Upvotes: 3
Reputation: 2618
You're going to want to enforce immutability here. So if you must mutate the first object in the array I would. I would try using the spread operator afterward.
cases[0]["name"] = "Michael"
cases = [...cases];
this will set cases
to a new instance of an array which should update the list.
Upvotes: 0