Hi,Is it possible to define a service which extends $http (or any other service)? Normally I would just use angular.extend(), but I have no idea what the second argument would have to be, as $http will be undefined.--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/6UeU-FHofxoJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
Well, I want all my controllers to use this custom $http (let's call it customHttp) service for future changes (rerouting requests, debugging, etc). Suppose functionality is added to the $http service which is the best choice for a certain controller. To use this functionality I would then also have to define this method in customHttp. If I use inheritance instead of composition, I would not have to worry about new functionality in $http.
On Thursday, July 19, 2012 5:28:58 PM UTC+2, Peter Bacon Darwin wrote:
How about composition? Write a service that has $http injected into it and uses it. This is what ngResource does.
Pete
On 19 July 2012 14:58, Dario Gieselaar <d.gie...@gmail.com> wrote:
Hi,Is it possible to define a service which extends $http (or any other service)? Normally I would just use angular.extend(), but I have no idea what the second argument would have to be, as $http will be undefined.
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/6UeU-FHofxoJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/rZ6lEYxgUrIJ.
That doesn't work with dependency injection. You could try decorating the service though if you wanted to modify the way $http works.
Pete
...from my mobile.
Hi Darlo,Well, remember it's just plain old Javascript:myHttp = function() {}
myHttp.prototype = new $http();
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/fzjyvutMT3kJ.