我有一个供应商,我想使用APP_INITIALIZER上的应用程序初始化运行它,但不知何故,我不断收到一个错误角2调用应用程序启动时服务
Unhandled Promise rejection: appInits[i] is not a function ; Zone: ; Task: Promise.then ; Value: TypeError: appInits[i] is not a function
这里是我的供应商:
@Injectable()
export class SendNotification {
constructor(public http: Http) {
Observable.interval(30 * 60 * 1000)
.switchMap(res =>this.http.get(`http://localhost:8100/api/balance.pl?meternumber=0003080123&api=json`))
.map(res => res.json())
.subscribe(res => this.check(res))
}
private check(res) {
console.log("Check wether to notify a user")
}
而且我app.module.ts,我打电话给供应商如下:
providers: [{provide: APP_INITIALIZER,useClass: SendNotification,deps:[Http],multi: true}]
})
任何帮助将不胜感激?
的方法'appInits'从你的代码名? –
不,我没有在我的代码... – bobin56