how can i extend a service

后端 未结 6 1317
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:40

    Your ExtendedServiceshould inject the BasicServicein order to be able to access it. Beside that BasicService is an object literal, so you can't actually call it as function (BasicService()).

    .factory('ExtendedService', function($http, BasicService){
      BasicService['method_four'] = function(){};
      return BasicService;
    }
    

提交回复
热议问题