是否有一个示例如何/在哪里使用 provide() 函数定义依赖注入?
我想将类和值映射到接口:
https://angular.io/docs/ts/latest/api/core/provide-function.html
尝试在 app.js 中这样做:
import {provide, Injector} from 'angular2/angular2';
export interface EnvSettings {
apiUrl: string;
}
var injector = Injector.resolveAndCreate([
provide(EnvSettings, {useValue: {apiUrl: 'http://localhost:8080/'}}),
//provide(Engine, {useClass: Engine}),
]);
收到错误:
Uncaught Token must be defined!