Now, the thing is that my console logs the response correctly on every button press, but the DOM isnāt updating. Once I click another button or open the sidemenu, ngFor displays all items correctly.
Using zone.run() is a workaround rather than a real solution. There was a bug in beta.4 which caused problems with the updates. Check out the linked post for more details:
it is unfortunate because keep seeing everyone suggesting the use of ngZone in the apps glad to see it being acknowledged as a workaround/hack as instead of a best practice
I actually tried using beta6 on a copy of the project following your guide without success. Besides that everything looked like android instead of iOS, I still got the same behavior with that function.
@finke Double-check if youāre not importing es6-shim somewhere, you should only have es6-shim.min.js in index.html. You can also remove es6-promise from package.json, it shouldnāt be needed anymore. Other than that it could be something with your environment (you could start a new blank project and copy only the minimal code needed to reproduce it) - are you testing on browser/emulator/device?
@iignatov I just reproduced it in a fresh project, but still the same. Also, it doesnāt matter if I use ionic serve or emulate it in the simulator. Iām not importing es6-shim somewhere, scanned the whole projectā¦
@iignatov That demo looks basically identical. Iām using TypeScript and the blank starter.
The thing is that the places variable on the instance gets set correctly and also the console log looks perfectly fine. It is somehow just not updating the view.
@finke I just created a new project (ionic start Test-beta6 blank --v2 --ts) and applied the code from the plunker and everything works as expected. So I guess that itās an environment specific problem. I did a quick search for Safari in the Angular 2 Issues and found the following bugs that seem to be related:
In my case, I use a service that returns subjects (observables) to components and updates (using .next()) the components with new values (the service gets new values from a server via http.get()). This works fine on Chrome and FF, but not on Safari. If I debug or put console.log() in the .subscribe functions in the components, I see the new values arriving, but they are not updated in the views in Safari.
@iignatov Itās the same with chromeā¦
Iāve edited the plunker so that the observable does not fire immediately like it is in my app, but it still works as it should.
EDIT: I copied the delayed function from plunker to my project and it works. Now, there must be some kind of error in my code. Here are the functions in comparison:
@finke The code looks OK. I guess that it might be something zone-related, e.g. like the following zone.js issue: Losing zone in RxJS and fetch. Iāll suggest you to check in which zone your code is being executed:
@iignatov Yeah, it is exactly that issue. Before I subscribe to the Observable, the current zone is āAngularā and once Iām in the subscription, the zone switches to ārootā.
In such case there is not much that you can do, other that using the zone.run() workaround. I would recommend you to use NgZone and to add comments about the workaround. Something like this (so that you can find it and remove it once the issue is fixed):
Iām yet another one whoās been beaten by the so called āzone bugā in Ionic 2. I donāt have anything to add except this has happened to me when using socket.io
Having read the docs of NgZone, the bug may be there because socket events are run by Ionic for some reason outside the page zone. It looks like the run method, brought me back to it!
After updating to Ionic 2 RC0 I still have problems with view updating If I dont use zone.run.
My case is using zeroconf plugin, the services added wonāt appear until a new event is detected (like slide menu dragged)