我收到此错误:错误:未元件厂发现TermsConditions
No component factory found for TermsConditions while using angular2-rc6.
我的路线图是这样的:
{
path: '',
component: TermsConditions
}
我收到此错误:错误:未元件厂发现TermsConditions
No component factory found for TermsConditions while using angular2-rc6.
我的路线图是这样的:
{
path: '',
component: TermsConditions
}
感谢您的帮助。我知道如何解决这个问题。
No component factory found for TermsConditions.
@NgModule({
declarations : [ TermsConditionsComponent ]
})
export default class TermsConditions {}
导入这个模块你的根模块。
@NgModule({
declarations : [ AppComponent ],
imports: [ BrowserModule, TermsConditions ],
bootstrap: [ AppComponent ]
})
export default class AppModule {}
在路由中使用组件如。
{
path : 'terms',
component : TermsConditionsComponent
}
`
这意味着你的模块没有在应用范围可这就是为什么你的组件没有被绑定到路由器。
您需要列出declarations
和entryComponents
部分中的条款。
entryComponents用于根级别的应用程序,不适用于子级别的应用程序。 –
但是它的工作方式 – Yougesh
entryComponents用于列出在任何组件树的模板中没有任何引用的组件。 –
您是否在导出'TermsConditions'组件? –
@MadhuRanjan:你能解释一下为什么这是必需的吗? @NgModule({ 进口:[RouterModule], 声明: TermsConditionsComponent ] }) 出口默认类TermsConditions {} –
'declarations'是使用模块内的部件,和'exports'是用于使用它外部。你可以阅读更多关于模块[这里](https://angular.io/docs/ts/latest/guide/ngmodule.html)和[常见问题](https://angular.io/docs/ts/latest/ cookbook/ngmodule-faq.html),他们深入地解释了这些概念。 –