在ionic2中使用另一个组件中的组件

时间:2016-12-14 00:41:07

标签: html angular 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>

我在我的&#34; @ NgModule&#34;中添加了两个。不幸的是我收到了这个错误:

  

directive_normalizer.js:92Uncaught Error:模板解析错误:仅限   void和外来元素可以自封闭&#34; footer-component&#34;

你知道为什么吗?

1 个答案:

答案 0 :(得分:3)

您设置了<footer-component><footer-component/>

<footer-component/>被识别为自我结束标记(/>)(如<input/>

要关闭标记,/应位于结束元素的开头。 (就像你在</ion-content>

中看到的那样

所以将您的<footer-component/>更改为</footer-component>

完整代码:

<ion-content>
  Hello
  <footer-component></footer-component>
</ion-content>
相关问题