Angular.js:值()的配置不注射() [英] Angular.js: value() not injected in config()
问题描述
可能重复:结果
<一href=\"http://stackoverflow.com/questions/12903338/angularjs-dependency-injection-of-value-inside-of-module-config\">AngularJS里面的值依赖注入module.config
我有麻烦()的值注入的app.config()。这里的code(CoffeeScript的)
I am having trouble getting the value() injected into the app.config(). Here's the code (coffeescript)
window.app = angular.module("app", [])
app.value("template_path", "assets/angular/templates/users")
app.config(["$routeProvider","template_path" ($routeProvider, template_path) ->
console.log template_path
它抛出一个未知供应商:从应用template_path错误
it is throwing an "Unknown provider: template_path from app" error
难道说的配置()方法不能与值()设定值注入?
我使用1.0.2
Could it be that the config() method cannot be injected with value() set values? I am using 1.0.2
推荐答案
是的,你是正确的怀疑:价值不能被注入到配置块。 配置块只能有常量和供应商注入
Yes, you were suspecting correctly: values can't be injected into the config block. The config block can only have constants and providers injected.
这篇关于Angular.js:值()的配置不注射()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!