在http.get
return this.http.get(this.urlToBackend)
.map((res: Response) => res.json())
.retryWhen(errors =>
errors
.zip(Observable.range(3, 15), (_, i) => i)
.flatMap(i => {
if (i >= 15) {
throw errors;
}
let t = (Math.pow(2, i)) * 1000;
return Observable.timer(t);
}))
.catch((error: any) => this.handleError(error, false, 0, this.urlToBackend));
继续收到此错误:
TypeError: this.http.get(...).map(...).retryWhen is not a function
at IOService.getUserDetails (http://localhost:4200/main.bundle.js:303:14)
at NavirComponent.ngOnInit (http://localhost:4200/main.bundle.js:3328:24)
at Wrapper_NavirComponent.ngDoCheck (/AppModule/NavirComponent/wrapper.ngfactory.js:22:53)
at CompiledTemplate.proxyViewClass.View_AppWrapperComponent0.detectChangesInternal (/AppModule/AppWrapperComponent/component.ngfactory.js:100:28)
at CompiledTemplate.proxyViewClass.AppView.detectChanges (http://localhost:4200/vendor.bundle.js:81933:14)
at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:4200/vendor.bundle.js:82128:44)
at CompiledTemplate.proxyViewClass.AppView.internalDetectChanges (http://localhost:4200/vendor.bundle.js:81918:18)
at CompiledTemplate.proxyViewClass.View_AppWrapperComponent_Host0.detectChangesInternal (/AppModule/AppWrapperComponent/host.ngfactory.js:29:19)
at CompiledTemplate.proxyViewClass.AppView.detectChanges (http://localhost:4200/vendor.bundle.js:81933:14)
at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:4200/vendor.bundle.js:82128:44)
at ViewRef_.detectChanges (http://localhost:4200/vendor.bundle.js:60587:20)
at http://localhost:4200/vendor.bundle.js:41131:67
at Array.forEach (native)
at ApplicationRef_.tick (http://localhost:4200/vendor.bundle.js:41131:25)
at ApplicationRef_._loadComponent (http://localhost:4200/vendor.bundle.js:41106:14)
答案 0 :(得分:2)
尝试添加导入
import "rxjs/add/operator/mergeMap";