我有此配置
data = [
{
CREATE_TS: "2018-08-15 17:17:30.0",
Key1: "Val1",
Key2: "Val2",
},
{
CREATE_TS: "2018-08-15 17:25:30.0",
Key1: "Val1",
Key2: "Val2",
},
{
CREATE_TS: "2018-08-15 17:28:30.0",
Key1: "Val1",
Key2: "Val2",
}
]
}
我的服务
angular.module('moduleApp.config')
.config(['$translateProvider', '$languageSupportProvider',
function($translateProvider, $languageSupportProvider) {
// I need to access myService.getLocale();
}]);
如果我尝试在配置中添加服务,则会出现错误。如何在配置中获取服务数据?
答案 0 :(得分:0)
angular.module("moduleApp")
.service("MyService", MyService);
function MyService() {
this.getLocale = function() {
// etc
return "en";
};
}
.config(['$translateProvider', '$languageSupportProvider', 'MyService'
function($translateProvider, $languageSupportProvider, MyService) {
var locale = MyService.getLocale();
}]);```