Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

DOM is not updating when I change the array that is binded to an ngFor

$
0
0

@ihadeed wrote:

Hello,

I'm building an app using Ionic 2 alpha 53, Angular 2, Typescript..

What I have is similar to the example below:

HTML
<ion-item *ngFor="#item in items">
...
</ion-item>

TypeScript
export class MyPage {
constructor() {
this.items = []; // Create a blank array to avoid start-up errors
MyProvider.getItems().then( items => {
this.items = items; // Update items
});
}
}

After the page is loaded and it successfully retrieved the items from my provider, it does not update the DOM. I would have to manually click on something such as an Action Sheet or a Side Menu to refresh the DOM and display the updated items.

Not sure why I'm having this issue... I looked at the sample Ionic Conference App and it seems like they're doing it exactly the same way.

...

Any thoughts?

EDIT: It seems like this issue only occurs when I try to replace the whole array. If I .push() or .splice() it updates fine. But again, Ionic Conference App is replacing the whole array and it works fine!

Posts: 9

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>