angularjs - Could I write a HttpInterceptor as a service? -


i'm rather confused on difference between factory , service , why 1 choose 1 on other. here have factory possible write service , if like? what's advantage of using service or factory here?

app.factory('testinterceptor', ['$q', function ($q) {      return {         'request': function (config) {             return config;         },         // optional method         'requesterror': function (rejection) {             return $q.reject(rejection);         },         // optional method         'response': function (response) {             return response;         },         // optional method         'responseerror': function (rejection) {             return $q.reject(rejection);         }     } }]);  app.config(['$httpprovider', function ($httpprovider) {     $httpprovider.interceptors.push('testinterceptor'); }]) 


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -