在页面上,我有几个Angular模块.对于每个模块,我定义一个包含模块版本的常量.
var module1 = angular.module('module1').constant('version', '1.2.3');
var module2 = angular.module('module2').constant('version', '2.0.0');
...
Run Code Online (Sandbox Code Playgroud)
我虽然在模块中定义了一个常量.但是当我在module1中使用常量时,我得到的值是'2.0.0'......
有没有办法定义一个适合模块的常量(或其他任何东西)?
编辑:对于替代解决方案,您能否解释一下如何使用它,例如在控制器声明中?
module2.controller('myCtrl', function( $scope, $http, $q, ..., version ){
// Here I can use the constant 'version'
}
Run Code Online (Sandbox Code Playgroud)