Cannot find primary outlet to load 'XYZCompone

2019-07-11 23:44发布

问题:

I've got ng2 code loading in a .Net MVC component but the following error displays in the console:

EXCEPTION: Uncaught (in promise): Error: Cannot find primary outlet to load 'UsersComponent' Error: Cannot find primary outlet to load 'UsersComponent'

Any idea what the issue might be? I'm using ng2-final and my app does work. However, I've been asked to dev a reference implementation so I need to make sure that errors don't display in the console after the page loads.

回答1:

This error usually occurs when you are using the Router and you haven't declared an outlet for the router to use in your HTML:

<router-outlet></router-outlet>