angularjs - Typescript writing angular $httpprovider defaults -
i trying write global angular $httpprovider
defaults in typescript. here code, have currently.
export class jsondateparser { private httpprovider:any; public static $inject = [ $httpprovider ]; constructor($httpprovider:any) { console.log("json date parser defaults"); this.httpprovider = $httpprovider; // gives me runtime error // referencing angular. } } // here reference registering app.config(jsondateparser);
- how can write angularjs
httpprovider
defaults in typescript? - also how can apply lambda syntax constructor in typescript.
- if assign
httpprovider
variableng.ihttpprovider
type, complier complainsthis.httpprovider.defaults.transformresponse
,transformresponse
not resolved. see in type definition angular.d.ts (1.2.x) not defined, should there right? missing something?
thanks in advance helping me out.
we need bit adjusted syntax:
// define parser export class jsondateparser { constructor(private $httpprovider:any) { console.log("json date parser defaults"); } } // register app.config(['$httpprovider', ($httpprovider) => new jsondateparser($httpprovider)]);
angular .config()
not flexible .service()
or .controller()
.
so have pass params controller inside of initialization arrow function. used array notation, way - later not suffer minifying
also, if delcare param private:
constructor(private $httpprovider:any) { ...
compiler create field , assign later can this.$httpprovider
Comments
Post a Comment