Issue
I have a simple button with spinner inside
<button class=" mybutton " ng-click="click()" id="servieren" ui-sref="menu.servieren"><ion-spinner ng-hide="showing" class="spinner-spiral"></ion-spinner>Servieren</button>
and when i click on the button the spinner starts spinning and page opens, all fine.
This is js code inside controllers.js
.controller('inhaltCtrl', function($scope) {
$scope.showing = true;
$scope.click = function(){
$scope.showing = false;
}
})
BUT when i go back to page where the button is, the spinner is still spinning and it eats out the cpu. How to stop the spinner once the page is opened?
Solution
This can be achieved with View LifeCycle and Events
ionViewDidLoad
: Fired only when a view is stored in memory. This event is NOT fired on entering a view that is already cached. It’s a nice place for init related tasks.ionViewWillEnter
: It’s fired when entering a page, before it becomes the active one. Use it for tasks you want to do every time you enter in the view (setting event listeners, updating a table, etc.).ionViewDidEnter
: Fired when entering a page, after it becomes the active page. Quite similar to the previous one.ionViewWillLeave
: Fired when you leave a page, before it stops being the active one. Use it for things you need to run every time you are leaving a page (deactivate event listeners, etc.).ionViewDidLeave
: Fired when you leave a page, after it stops being the active one. Similar to the previous one.ionViewWillUnload
: Fired when a view is going to be completely removed (after leaving a non-cached view).
Answered By - Tomislav Stankovic
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.