angularjs - Inject Dependencies into Static Factory in Typescript -


i have service written in typescript class. in class define static factory inject dependencies.

when compress application, dependencies being compressed , receive undefined provider error.

here service:

export class tinterceptor {     public static $inject = ['$q', '$rootscope']; public static factory($q:ng.iqservice, $rootscope:ng.irootscopeservice) {   return new tinterceptor($q, $rootscope); } constructor(private $q:ng.iqservice, private $rootscope:ng.irootscopeservice){}...} 

service being called here:

  angular     .module('t')     .config(config);    function config($httpprovider:ng.ihttpprovider)   {     $httpprovider.interceptors.push(tinterceptor.factory);   } 

my question is, how make sure dependencies protected being overwritten when compress code?

register factory. i.e,

angular.module('myapp').factory('interceptorfactory', ['$q','$rootscope',tinterceptor.factory]); 

and in config block provide factory name:

$httpprovider.interceptors.push('interceptorfactory'); 

or supply array (guess should work internally uses $injector.invoke not string)

 $httpprovider.interceptors.push(['$q','$rootscope', tinterceptor.factory]); 

you forgot explicit annotation on config block well.

.config(['$httpprovider', config]); 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -