Issue
I have a page in my Angular.js app that does a http request and fills in some textboxes with the results.
I navigate to this page by using :
$state.go('utab.history');
but when it gets to the page all the textboxes are blank, i am currently using Ionics ion refresher :
<ion-refresher
pulling-text="Pull to refresh..."
on-refresh="showappraisal()">
</ion-refresher>
to call the controllers function which then populates all the textboxes, but now the apps nearly done i need to solve this issue.
I have tried using $rootScope.$emit("CallParentMethod", {});
just before $state.go('utab.history');
and it does run the function but again, it just doesnt populate the textboxes until i do the pull refresh (even though they call the same function).
Is there a way to get an event when utab.history loads?
Solution
Add a listener function in your view controller, and make changes whatever you want.
app.controller("yourcontroller", ['$scope', '$ionicView', function($scope, $ionicView){
$scope.$on('$ionicView.afterEnter', function(e){
//You can call your functions
});
});
or
app.controller("yourcontroller", ['$scope', '$ionicView', function($scope, $ionicView){
$scope.init = function(){
$scope.$on('$ionicView.afterEnter', function(e){
//You can call your functions
});
}
$scope.init(); //initialize by your own
});
There are so many events are available while navigating from one view to another.
Available Events:
loaded, enter, leave, beforeEnter, beforeLeave, afterEnter, afterLeave, unloaded.
You can listen any of the above events for your convenience.
Refernce : http://ionicframework.com/docs/api/directive/ionView/
Answered By - Gopinath Ravichandran
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.