3 ms·
Nope, they're all singletons. While providers may be useful, the distinction between service and factory is completely useless (service is completely unnecessar
by spion 13y ago
Nope, they're all singletons. While providers may be useful, the distinction between service and factory is completely useless (service is completely unnecessary :)
At this point the angular team should probably just deprecate module.service and remove it from the docs to avoid causing this massive confusion.
- jonny_eh 13y agoWhy 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.
- spion 13y agoBecause .factory is slightly more general (can return non-objects), and it can't be called .service because backward compatibility.
- jonny_eh 13y agoThe 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?
- minznerjosh 13y ago.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? });
- alttab 13y agoI want the bike shed to be blue, god dammit!