请参阅以下代码
import { Http,HttpModule} from '@angular/http';
import { Injectable,Inject } from '@angular/core';
import 'rxjs/add/operator/toPromise';
export class FINAL
{
static configs:{};
@Inject(Http) http:Http;
constructor()
{
if(FINAL.configs === undefined)
{
console.log('get configs ...');
this.http.get('../config.json').toPromise().then(response => {
FINAL.configs = response;
return true;
})
}
}
}
this.http
未定,为什么?如果我使用constructor( @Inject(Http) http:Http;)
:我如何通过显式FINAL
来获取new xx()
类的实例?