【发布时间】:2014-08-10 21:48:27
【问题描述】:
我在使用 angular-config 注入常量“ACCESS_LEVELS”时遇到问题?
因为当我喜欢下面的代码时,得到消息:Uncaught Error: [ng:areq] http://errors.angularjs.org/1.2.14/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20string
即:Argument 'fn' is not a function, got string
如果我用注入删除“ACCESS_LEVELS”,我就没有访问路径。
var app = angular.module("app", ["ngRoute", "ngAnimate"])
.constant('ACCESS_LEVELS', {
guest: 1,
user: 2,
admin: 3
});
app.config(["$routeProvider", "$locationProvider", "ACCESS_LEVELS", function($routeProvider, $locationProvider, ACCESS_LEVELS) {
$routeProvider
.when("/", {
template: "",
label: "Home",
access_level: ACCESS_LEVELS.user
})
.
.
.
}]);
也许我犯了一个简单的错误,但我看不到。 如果有人知道如何解决这个问题,请帮忙。
问候
【问题讨论】:
-
请提供一个完全隔离的可重现的现场示例。