나는 제공자에 대해 약간의 의문이있다. 컨트롤러에서 "setText"공급자 기능에 액세스 할 수없는 이유를 설명 할 수 있습니까? $ get 블록 안에있는 함수에만 접근 할 수 있습니다.
var myMod = angular.module('myApp', []);
myMod.controller("mainCtrl", [ "$scope","greeting", function($scope, greeting){
greetingProvider.setText("Hi, ");
}]);
myMod.provider('greeting', function() {
var text = 'Hello, ';
this.setText = function(value) {
text = value;
};
this.$get = function() {
return function(name) {
console.log(text + name);
};
};
});
myMod.config(function(greetingProvider) {
greetingProvider.setText("Howdy there, ");
});
myMod.run(function(greeting) {
greeting('Ford Prefect');
});
감사