Search code examples
nativescriptangular2-nativescriptnativescript-angular

Re-render Nativescript ListView when ObservableArray item changes


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"


Solution

  • 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);
            });
         });