Re:AngularJS: Factory vs. Service vs. Provider
by jonny_eh on Sunday May 04, 2014 @09:51PM
(#7696650)
Why not the other way around? You can use .service as you would a .factory, and it makes sense that .service is used to create services just like .controller creates controllers.
[ Parent
| on HN ]
Because .factory is slightly more general (can return non-objects), and it can't be called .service because backward compatibility.
Re:AngularJS: Factory vs. Service vs. Provider
by jonny_eh on Sunday May 04, 2014 @10:34PM
(#7696742)
The article seems to be down for me. Can you give an example of a case where a .service won't cut it but a . Factory would?
Re:AngularJS: Factory vs. Service vs. Provider
by minznerjosh on Sunday May 04, 2014 @10:44PM
(#7696759)
.factory('$timeout', function($window) {
var $timeout = $window.setTimeout;
return $timeout;
}).service('$timeout', function($window) {
// $timeout is a function, not an normal object. Why would I use a constructor
//function to provide it?
});