I'm trying to watch the resume
event when the app resumes. I used to have this working but ionic changed things up and now I'm having trouble. I'm sure it's an easy fix.
This used to work but no longer does:
$ionicPlatform.on('resume', function(){
//rock on
});
The docs now suggest using the following but I'm not sure which DOM element to use.
angular.module('starter', ['ionic', 'starter.controllers'])
.run(function() {
ionic.Platform.ready(function() {
ionic.on('resume', function(){
//rock on
}, element);
});
});
Also, should the ionic.on()
function be in the ionic.Platform.ready()
function?
Ok, answered my own question.
It didn't change. I was wrong. The following works.
angular.module('starter', ['ionic', 'starter.controllers'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// ready
});
$ionicPlatform.on('resume', function(){
// rock on
});
});
It is unclear in the docs though. It says here
$ionicPlatform An angular abstraction of ionic.Platform.
so the following should work but it doesn't:
ionic.Platform.on('resume', function(){
// rock on
});