AngularJS - 从控制器获取模块常量
- 论坛
- AngularJS - 从控制器获取模块常量
19 浏览
AngularJS - 从控制器获取模块常量
我正在尝试构建一个myApp.config模块来存储我的应用程序的一些设置,我编写了一个config.js文件:
angular.module('myApp.config', []) .constant('APP_NAME','My Angular App!') .constant('APP_VERSION','0.3');
我将它添加到我的app.js (angular-seed) 中:
angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives', 'myApp.controllers', 'myApp.config']).
我将它添加到index.html文件中,现在我正在尝试弄清楚如何在我的控制器中获取它,我尝试了:
angular.module('myApp.controllers', ['myApp.config']) .controller('ListCtrl', ['$scope', 'myApp.config', function($scope, $config) { $scope.printme = $config; }])
但是我得到了这个错误信息:
Unknown provider: myApp.configProvider <- myApp.config
我可能在这里做错了什么,有什么想法吗?