2016-12-14 31 views
-1

我有一個組件使用組件在另一個組件中ionic2

import { Component } from '@angular/core'; 

@Component({ 
    selector: 'footer-component', 
    templateUrl: 'footer.html' 
}) 
export class FooterComponent {} 

,並想使用另一種一個像

<ion-content> 
    Hello 
    <footer-component><footer-component/> 
</ion-content> 

我都在我的「@NgModule」補充道。不幸的是我得到這個錯誤:

directive_normalizer.js:92Uncaught Error: Template parse errors: Only void and foreign elements can be self closed "footer-component"

你知道爲什麼嗎?

回答

3

您設置<footer-component><footer-component/>

<footer-component/>被認爲是自行閉合的標籤(在/>)(如<input/>

要關閉一個標籤/應該在封閉元件的開始。(喜歡你看到</ion-content>

因此改變你的<footer-component/></footer-component>

˚F ull代碼:

<ion-content> 
    Hello 
    <footer-component></footer-component> 
</ion-content> 
+0

有時你花這麼多時間去做那種容易的事情......謝謝! –

相關問題