The goal
To have an event fire, preferably before the view is loaded, so I can reach out to the server and gather information for that view.
The problem
The $ionicView events are not firing, or at least not being detected by AngularJS. If I run the application in (ionic serve
) the browser, there are no problems, and all events fire as they should.
What I’ve tried
What I usually do (for a web application):
angular.element(document).ready(function () {
// ...
});
A more globalized attempt:
$rootScope.$on("$routeChangeStart", function(event, next, current) {
console.log(event, next, current);
});
A controller scoped attempt:
$scope.$parent.$on('$ionicView.beforeEnter', function(ev, info) {
console.info('$scope.$parent beforeEnter=' + info.stateName);
});
$scope.$on('$ionicView.loaded', function(ev, info) {
console.info('node loaded');
});
$scope.$on('$ionicParentView.beforeEnter', function(ev, info) {
console.info('parentview node before enter');
});
$scope.$on('$ionicView.beforeEnter', function(ev, info) {
console.info('node before enter');
});
$scope.$on('$ionicParentView.enter', function(ev, info) {
console.info('parentview node enter');
});
$scope.$on('$ionicView.enter', function(ev, info) {
console.info('node enter enter');
});
Here is my ionic info
:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.15.2 ionic (Ionic CLI) : 3.15.2
global packages:
cordova (Cordova CLI) : 7.1.0 Gulp CLI : CLI version 3.9.1 Local version 3.9.1
local packages:
Cordova Platforms : android 6.3.0 ios 4.5.2 Ionic Framework : ionic1 1.3.3
System:
Android SDK Tools : 26.1.1 Node : v8.6.0 npm : 5.3.0 OS : Linux 4.13
Environment Variables:
ANDROID_HOME : /home/dave/Android/Sdk
Misc:
backend : pro