AngularJS - Ionic : execute code in controller when coming back to it -
i'm new in angularjs community , i'm developping first app framework.
i created new controller code :
.controller('accountctrl', function($scope, $location) { alert('test'); })
and route :
.state('app.account', { url: "/account", views: { 'menucontent': { templateurl: "templates/account.html", controller: 'accountctrl' } } })
the alert popup shown first time access controller. but, if change url , come accountctrl (with classic html a), alert popup not shown again.
could explain me why ?
thanx !
in ionic framework views , controllers cached default. ma add listener views scope receive notification when view re-active again. more information see: http://ionicframework.com/docs/api/directive/ionview/ , http://ionicframework.com/docs/api/directive/ionnavview/
you may disable cache on view <ion-view cache-view="false">
.controller('accountctrl', function($scope, $location) { $scope.$on('$ionicview.beforeenter', function () { // update campaigns everytime view becomes active // (on first time added dom , after view becomes active after cached alert('test'); }); })`
Comments
Post a Comment