常数和价值之间有什么区别?我们能够改变这两个价值观.
var app = angular.module(‘myApp’,[]); app.constant(‘appName’,‘My App’); app.value(‘applicationName’,‘Sample’);
解决方法
常量可以放在任何地方,而值不能添加到任何地方.此外,常量不能被装饰器拦截,而值可以被装饰器拦截.
另请参阅:Value and Constants
The difference between a value and a constant service is that the former can only be injected (and thus be used) in a service or a controller while the latter can also be injected into a module configuration function.. (I will discuss the module configuration function in a future post).