我是角度js的新手,我正试图路由到spa应用程序中的状态
因为我尝试了以下代码
app.run(function ($rootScope, $state,$cookieStore) {
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
if(toState.authenticate){
if($cookieStore.get('clientID')!=null || $cookieStore.get('profile') !=null) {
if($cookieStore.get('profile') == 0){
event.preventDefault();
$state.transitionTo("profile");
}
}else{
event.preventDefault();
$state.transitionTo("signin");
}
}
if(toState.authentication){
if($cookieStore.get('clientID')!=null || $cookieStore.get('profile') !=null) {
}else{
event.preventDefault();
$state.transitionTo("signin");
}
}
if(toState.loggedin){
if($cookieStore.get('clientID')!=null){
event.preventDefault();
$state.transitionTo("dashboard");
}
}
});
});
但是,我收到了这个错误
angular.js:13708
Error: [$rootScope:infdig] http://errors.angularjs.org/1.5.7/$rootScope/infdig?p0=10&p1=%5B%5D
at Error (native)
at http://localhost/spa/bower_components/angular/angular.min.js:6:412
at m.$digest (http://localhost/spa/bower_components/angular/angular.min.js:143:281)
at m.$apply (http://localhost/spa/bower_components/angular/angular.min.js:145:401)
at http://localhost/spa/bower_components/angular/angular.min.js:20:457
at Object.invoke (http://localhost/spa/bower_components/angular/angular.min.js:41:376)
at c (http://localhost/spa/bower_components/angular/angular.min.js:20:378)
at Bc (http://localhost/spa/bower_components/angular/angular.min.js:21:163)
at ge (http://localhost/spa/bower_components/angular/angular.min.js:19:484)
at http://localhost/spa/bower_components/angular/angular.min.js:315:135
任何人都可以帮我解决这个错误,我尝试使用$state.go()
但我得到了同样的错误 请帮我解决这个错误或给我一个路由解决方案, 提前谢谢