作用
Module.value(key, value) is used to inject an editable value 如何使用
var app = angular.module('app', []);
app.value('myConstant', 'weee');
// use it in a service
myService.$inejct = ['myConstant'];
function myService(myConstant){
return {
whatsMyThing: function() {
return myConstant; //weee
}
};
}
// use it in a controller
app.controller('someController', someController);
someController.$inject = ['myConstant'];
function someController(myConstant) {
var vm = this;
vm.foo = myConstant;
}
参考
https://docs.angularjs.org/api/auto/service/$provide http://stackoverflow.com/questions/13015523/angular-js-is-value-the-proper-way-to-set-app-wide-constant-and-how-to-retri