我收到此錯誤:錯誤:未元件廠發現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),他們深入地解釋了這些概念。 –