3 ms·
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 cr
by jonny_eh 13y ago
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.
- 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!