javascript - Using $state.go() with onResume() -
i trying redirect login page each time application comes background foreground error : uncaught typeerror: $state.go not function
so did wrong, can't what.
here parts of code in app.js :
// ionic starter app angular.module('starter', ['ionic', 'starter.controllers', 'starter.services']) .config(function($stateprovider, $urlrouterprovider) { $stateprovider .state('resetlogin', { url: '/resetlogin', templateurl: 'templates/resetlogin.html', controller: 'resetloginctrl' }) .state('login', { url: '/login', templateurl: 'templates/login.html', controller: 'loginctrl' }) .state('tab', { url: '/tab', abstract: true, templateurl: 'templates/tabs.html' }) .state('tab.account', { url: '/account', views: { 'tab-account': { templateurl: 'templates/tab-account.html', controller: 'accountctrl' } } }); $urlrouterprovider.otherwise('/login'); }) .run(function($ionicplatform, $state) { $ionicplatform.ready(function() { if (window.cordova && window.cordova.plugins && window.cordova.plugins.keyboard) { cordova.plugins.keyboard.hidekeyboardaccessorybar(true); } if (window.statusbar) { statusbar.styledefault(); } }); function ondeviceready() { } }); document.addeventlistener("resume", onresume, false); function onresume($state){ $state.go('login'); }
juste move function in block run , remove $state in onresume. angular function injectable. in fact you're getting event object in case surely not $state.
.run(function($ionicplatform, $state) { $ionicplatform.ready(function() { if (window.cordova && window.cordova.plugins && window.cordova.plugins.keyboard) { cordova.plugins.keyboard.hidekeyboardaccessorybar(true); } if (window.statusbar) { statusbar.styledefault(); } }); function ondeviceready() { } document.addeventlistener("resume", onresume, false); function onresume(){ $state.go('login'); } });
Comments
Post a Comment