Thursday, February 11, 2016

Diff Between factory an service in Angular js?

1). Factories are functions that return the object, while services are constructor functions of the object which are instantiated with the new keyword.


angular.module('app').factory('SomeService', function() { return { someFunction: function() {} }; });


angular.module('app').service('SomeService', function() { this.someFunction = function() {}; });

No comments:

Post a Comment