我创建了一个函数来验证Cookie是否存在,并且我想在每个页面中使用angularjs运行此函数.我似乎无法使该功能运行.我应该将模块放在新控制器中吗?
这是我到达的距离:
angular.module('myApp', ['ngCookies']).
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/products', {templateUrl: '/tmpl/products.html', controller: Ctrl}).
otherwise({redirectTo: '/index'})
}]).run( function($rootScope, $location) {
//should I call it here?
//validateCookie();
});
function validateCookie($scope, $cookieStore, $http){
}
Run Code Online (Sandbox Code Playgroud)