找不到要加载"XYZComponent"的主出口 [英] Cannot find primary outlet to load 'XYZComponent'
问题描述
我在.Net MVC组件中加载了ng2代码,但控制台中显示以下错误:
I've got ng2 code loading in a .Net MVC component but the following error displays in the console:
例外:未捕获(承诺):错误:找不到要加载"UsersComponent"的主要出口 错误:找不到要加载"UsersComponent"的主要插座
EXCEPTION: Uncaught (in promise): Error: Cannot find primary outlet to load 'UsersComponent' Error: Cannot find primary outlet to load 'UsersComponent'
任何想法可能是什么问题?我正在使用ng2-final,而我的 app 确实可以正常工作.但是,我被要求开发一个参考实现,因此我需要确保页面加载后不会在控制台中显示错误.
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.
推荐答案
当您使用路由器并且尚未声明路由器在HTML中使用的插座时,通常会发生此错误:
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>
这篇关于找不到要加载"XYZComponent"的主出口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!