close

  menu      DavidRodenas
CONTACT  
Main article: Providers »

Angular providers

May 08, 2015

One of the most difficult parts to AngularJS newcomers is now in Teaching section.

Tags: angularjs-provider, teaching, angularjs


function Logger() {
    this.log = function(msg) { console.log(msg); };
}
// ..choose..
module.value('logger', new Logger());
// ..or..
module.service('logger', Logger);
// ..or..
module.factory('logger', function() { return new Logger(); });
// ..or..
module.provider('logger', function() {
    this.$get = function() { return new Logger(); };
});

« Back to List