Angular4:路由器无法正常工作。路由错误:错误:序列中没有元素

时间:2017-12-03 14:04:09

标签: javascript angular angular-routing

我已经使用以下某种模式指定了网址。

  • streamz / ABC
  • streamz /搜索/ XYZ
  • streamz / ABC / 123

为此我创建了如下路由器。

{ path: 'streamz/:name', loadChildren: './streamz-message/streamz-message.module#StreamzMessageModule' },
{ path: 'streamz/search/:id', loadChildren: './streamz-search/streamz-search.module#StreamzSearchModule' },
{ path: 'streamz/:brand/:id', loadChildren: './streamz-detail/streamz-detail.module#StreamzDetailModule' },

直到昨天这个工作正常。一旦我安装新的node_modules,这是行不通的。这会引发如下错误。

  

router-error-handling.ts:12路由错误:错误:序列中没有元素       at new EmptyError(EmptyError.js:27)       在FirstSubscriber.webpackJsonp ... / .. / .. / .. / rxjs / operators / first.js.FirstSubscriber._complete(first.js:154)       在FirstSubscriber.webpackJsonp ... / .. / .. / .. / rxjs / Subscriber.js.Subscriber.complete(Subscriber.js:121)       在MergeMapSubscriber.webpackJsonp ... / .. / .. / .. / rxjs / operators / mergeMap.js.MergeMapSubscriber._complete(mergeMap.js:144)       在MergeMapSubscriber.webpackJsonp ... / .. / .. / .. / rxjs / Subscriber.js.Subscriber.complete(Subscriber.js:121)       在MapSubscriber.webpackJsonp ... / .. / .. / .. / rxjs / Subscriber.js.Subscriber._complete(Subscriber.js:139)       在MapSubscriber.webpackJsonp ... / .. / .. / .. / rxjs / Subscriber.js.Subscriber.complete(Subscriber.js:121)       at EmptyObservable.webpackJsonp ... / .. / .. / .. / rxjs / observable / EmptyObservable.js.EmptyObservable._subscribe(EmptyObservable.js:82)       at EmptyObservable.webpackJsonp ... / .. / .. / .. / rxjs / Observable.js.Observable._trySubscribe(Observable.js:173)       at EmptyObservable.webpackJsonp ... / .. / .. / .. / rxjs / Observable.js.Observable.subscribe(Observable.js:161)   CustomRoutingExtraOptions.errorHandler @ router-error-handling.ts:12   (匿名)@ router.es5.js:4194   webpackJsonp ... / .. / .. / .. / zone.js / dist / zone.js.ZoneDelegate.invoke @ zone.js:391   onInvoke @ core.es5.js:3890   webpackJsonp ... / .. / .. / .. / zone.js / dist / zone.js.ZoneDelegate.invoke @ zone.js:390   webpackJsonp ... / .. / .. / .. / zone.js / dist / zone.js.Zone.run @ zone.js:141   (匿名)@ zone.js:831   webpackJsonp ... / .. / .. / .. / zone.js / dist / zone.js.ZoneDelegate.invokeTask @ zone.js:424   onInvokeTask @ core.es5.js:3881   webpackJsonp ... / .. / .. / .. / zone.js / dist / zone.js.ZoneDelegate.invokeTask @ zone.js:423   webpackJsonp ... / .. / .. / .. / zone.js / dist / zone.js.Zone.runTask @ zone.js:191   drainMicroTaskQueue @ zone.js:595   webpackJsonp ... / .. / .. / .. / zone.js / dist / zone.js.ZoneTask.invokeTask @ zone.js:502   invokeTask @ zone.js:1364   globalZoneAwareCallback @ zone.js:1382

上述路由模式出了什么问题。请帮助。

1 个答案:

答案 0 :(得分:2)

我也遇到了这个错误。它是由RxJS 5.5.3中的错误引起的。我已将RxJS依赖关系更改为:

"rxjs": "5.5.2"

这解决了这个问题。