【发布时间】:2016-03-23 20:01:17
【问题描述】:
我是这样做的:
import {testInjection} from './ts/models';
import {bootstrap} from 'angular2/platform/browser';
bootstrap(AppComponent, [testInjection]).catch(err => console.error(err));
在models.ts中
let TEST:string = "test";
export var testInjection: Array<any>=[
bind(TEST).toValue(TEST)
];
然后在 AppComponent 中:
class export AppComponent{
constructor(
public http: Http,
@Inject(TEST) TEST:string
){
}
}
但收到此错误:错误 TS2304:找不到名称“TEST”。 谁能指出我做错了什么。
tnx
【问题讨论】:
标签: angular2-services angular2-di angular2-injection