AngularJS – provide
HTML
<div ng-app='app'></div>
JavaScript
angular.module('app', ['greeting']).run(function(greeting) {
console.log(greeting('John'))
})
angular.module('greeting', []).provider('greeting', function() {
var text = 'Hello, ';
this.setHelloText = function(value) {
text = value;
}
this.$get = function() {
return function(name) {
console.log(text, name);
}
};
}).config(function(greetingProvider) {
greetingProvider.setHelloText('Witaj, ');
});