var app = angular.module('wechat', ['ngRoute']); app.constant('config', { rootPath: '/assets/wechat/', rootUrl: '/', apiUrl: '/api/v1/' }); app.run(['$rootScope', 'auth', '$location', '$routeParams', function($rootScope, auth, $location, $routeParams){ $rootScope.$on('$routeChangeError', function(event, next, current){ if(next && next.templateUrl){ if(!next.templateUrl.endsWith("login.html") && !next.templateUrl.endsWith("reg.html")){ $location.path("/login"); } } }); $rootScope.$on('$routeChangeStart', function(event, next, current){ console.log($routeParams); if(next && next.templateUrl){ if(!next.templateUrl.endsWith("login.html") && !next.templateUrl.endsWith("reg.html")){ } } }); } ]);