我正在尝试从 angular1.5 组件初始化 test.service.js
,但我真的不知道该怎么做。我已将这种结构用于 Angular 分量:
var testComponent = {
templateUrl: "app/components/test.component.html",
controllerAs: "mvm",
bindings:{
bindingInput: "=",
},
controller: function(){
var mvm = this;
}
};
angular.module('myApp').component('testComponent', testComponent);
最佳答案
只需使用 Controller 注入(inject)它,如下所示:
...
},
controller: ['testService', function(testService){
var mvm = this;
}],
...
关于javascript - 将服务注入(inject) Angular 1.5 组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47670607/