【发布时间】:2013-11-14 22:25:26
【问题描述】:
我定义了一个.constant(),它充当服务访问的基本 URL。然后,我有几个具有相对 URL 路径的常量,我想在其前面添加基本 URL 以使其成为绝对值。
是否可以从另一个常量或值中访问 .constant() 或 .value()?
angular.module('App')
.constant('baseurl', 'http://www.example.com')
.constant('posturl', baseurl + '/posts')
【问题讨论】:
-
如果打算有多个常量,一个常量也可以是对象。减少将一件事作为依赖项而不是众多个人注入的麻烦
标签: javascript angularjs constants