Angular2 Can't resolve all parameters for RouterOutlet: (RouterOutletMap, ViewContainerRef, ?, name)

落花浮王杯 提交于 2019-12-05 18:33:48
José Yánez

For anyone having this issue.

This could happen when one Angular dependency gets updated through npm while some other internal component points to a previous version.

The question mark in the error means that Angular failed to provide an instance to the third DI parameter in the RouterOutlet component. When examined closely in the Debugger we can clearly see (And by clearly I mean after reading the line 2486 of the routing.umd.js file) that the third parameter "ComponentFactoryResolver" is missing.

Can't resolve all parameters for RouterOutlet: (RouterOutletMap, ViewContainerRef, ?, name)

I recommend the following steps.

  1. npm uninstall @angular --save
  2. Update your packages.json with the latest dependencies from https://angular.io/guide/quickstart
  3. npm install

Didn't have to reverse router version. All that works now on 3.0.0-beta.1.

Now it works as supposed, I'm not getting that error anymore (not like I dont get others now, but that have nothing to do with question).

WHAT I DID sorted by plausibility of resolving issue

  1. Precompiled components in app.component

    precompile: [HelloComponent, HalComponent, DaveComponent]

  2. Redirecting now set to full path match

    export const routes: RouterConfig = [ { path: '', redirectTo: '/hello', pathMatch: 'full' } ... ];

I too got this error "Can't resolve all parameters for RouterOutlet: (RouterOutletMap, ViewContainerRef, ?, name)."

For me, the routing breaks after I upgrade to 3.0.0-beta.1 from 3.0.0-alpha.8. Trying reverting back to the alpha version.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!