how can i extend a service

后端 未结 6 1292
Happy的楠姐
Happy的楠姐 2020-12-08 07:00

I am fairly new to angularjs and am not able to find any documentation or examples for this. What I am looking to do is to extend a basic service so that i can use the metho

6条回答
  •  醉梦人生
    2020-12-08 07:42

    In my opinion, a better way:

    .factory('ExtendedService', function($http, BasicService){
        var service = angular.copy(BasicService);
    
        service.methodFour = function(){
            //code for method four
        };
    
        return service;
    });
    

    Here at least does not change the inherited service.

提交回复
热议问题