Hi,
I transformed my promises call by Observable. When reading examples, I found that they usually put their calls (ex: http.get.subscribe) inside ngOnInit.
If I need to refresh my page, do you suggest to call ngOnInit or execute something else?
Hi,
I transformed my promises call by Observable. When reading examples, I found that they usually put their calls (ex: http.get.subscribe) inside ngOnInit.
If I need to refresh my page, do you suggest to call ngOnInit or execute something else?
If your observable needs to load during a lifecycle state, you should attach it to that state (such as ngOnInit as mentioned above).
I would prefer the Ionic lifecycle states over the Angular one though. See this page for reference. https://webcake.co/page-lifecycle-hooks-in-ionic-2/
big thanks for the link and advice!
@swarner Ionic lifecycle states doesn’t trigger change detection witch async calls, in my project
onPageLoaded() { setTimeout( () => { this.testval1 = 'loaded'; }, 3000);
putting it in a ngOnInit() {} does the job well, same for observables