angular.module(‘starter’, [‘ngCookies’,
‘ionic’,
‘ionic-material’,
‘ionMdInput’,
‘app.appController’,
‘app.loginController’,
‘app.friendsController’,
‘app.activityController’,
‘app.galleryController’,
‘app.profileController’])
.run(function($ionicPlatform, $rootScope, $cookieStore, $state) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
// Check login session
$rootScope.$on('$stateChangeStart', function(event, next, current) {
var userInfo = $cookieStore.get('userInfo');
if (!userInfo)
{
// user not logged in | redirect to login
if (next.name !== "welcome")
{
// not going to #welcome, we should redirect now
event.preventDefault();
$state.go('welcome');
}
}
else if (next.name === "welcome")
{
event.preventDefault();
$state.go('welcome');
}
});
})
this is code
but it has error with $cookieStore, what`s problem.???
I add cookie lib.
Uncaught Error: [$injector:unpr] http://errors.angularjs.org/1.3.13/$injector/unpr?p0=%24%24cookieReaderProv…okieReader%20<-%20%24cookies%20<-%20%24cookieStore%20<-%20%24cookies