I am using the angular seed project and try to use ui-router for user login based routing. I get following error in the console:
我正在使用角种子项目,并尝试使用ui-router作为基于用户登录的路由。我在控制台有以下错误:
Uncaught Error: [$injector:modulerr] Failed to instantiate module MyApp due to:
Error: [$injector:modulerr] Failed to instantiate module ui.router due to:
Error: [$injector:modulerr] Failed to instantiate module ui.router.state due to:
Error: [$injector:modulerr] Failed to instantiate module ui.router.router due to:
Error: [$injector:modulerr] Failed to instantiate module ui.router.util due to:
TypeError: forEach is not a function
at new $UrlMatcherFactory
...
My code in app.js is:
我在app.js中的代码是:
'use strict';
// Declare app level module which depends on views, and components
angular
.module('MyApp', [
'ui.router'
])
.config(['$stateProvider', function($stateProvider) {
$stateProvider
.state("root", {
url: "",
template: "<section ui-view></section>",
controller: function($state, user) {
if ($state.is("root")) $state.go(user.loggedIn ? "main" : "login");
}
})
.state("login", {
templateUrl: "login/login.html",
controller: "LoginCtrl"
})
.state("main", {
templateUrl: "main/main.html",
controller: "MainCtrl"
});
}])
.controller("MainCtrl", function($scope, user, $state) {
$scope.user = user;
$scope.logout = function() {
user.loggedIn = false;
$state.go("root");
}
})
.controller("LoginCtrl", function($scope, user, $state) {
$scope.login = function() {
user.loggedIn = true;
$state.go("root");
}
});
I didn't find anything with Google and hope someone can help me here. Best regards
我在谷歌没有找到任何东西,希望有人能在这里帮助我。致以最亲切的问候
1 个解决方案
#1
0
Probably a solution here ?
可能是一个解决方案?
See this link : https://github.com/ded/script.js/issues/86
参见这个链接:https://github.com/ded/script.js/issues/86
#1
0
Probably a solution here ?
可能是一个解决方案?
See this link : https://github.com/ded/script.js/issues/86
参见这个链接:https://github.com/ded/script.js/issues/86