I want to override or add some more functionality to existing services like $http, $log and so on how to do that?
Asked
Active
Viewed 624 times
0
-
The source code is here https://github.com/angular/angular.js/tree/master/src fork it and add your code. – georgeawg Jan 06 '16 at 09:01
1 Answers
1
You would need to use the $provide.decorator method for extending any angular services, the definition of a decorator as per the angular docs:
A service decorator intercepts the creation of a service, allowing it to override or modify the behavior of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service.
Came across this link by Freek Wielstra which might help you in taking this further.
Edit: Please check this SO answer by @tomakisquare, he has provided a brilliant plunkr example to extend third party services (or any service for that matter) without meddling with the original code.