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!
I guess this is a bug of Angular 2 because I have a similar problem for image. The image will not be shown after I pick it from the photolibary until I scroll my page or click a button.
That means anything inside a callback or a promise doesn’t work well for some reasons.
But this will work:
setTimeout( () => {
// update your data
},500)
Don’t know the difference between timeout callback and the provider callback. In my case, I’m using cordova image picker or camera plugin.
$http no longer exists in Angular 2 so I assume you mean Http.
Using the example here “MyProvider.getItems()”, it totally depends on what getItems function is returning. In Angular 2 using the Http service returns something called an Observable which is part of the new RxJs library.
Unfortunately, I’m not familiar with PouchDB. However, I can tell you that the reason they can call this.load().then is because they are returning a Promise object from the load function. Try this:
It’s strange though, the .then() was firing off before and console logging stuff for me. And if I click anywhere it actually updates the DOM. However, after wrapping my provider function with a promise it updates the DOM once it gets the data for me.