Ionic2 Unhandled Promise rejection:模板解析错误:' ion-item-content'不是已知元素:错误

时间:2017-01-16 11:26:52

标签: angular ionic-framework ionic2

这是我movie-info.html的代码:

<ion-header>
<ion-navbar>
  <ion-title>
    Movie Info
  </ion-title>
</ion-navbar>
</ion-header>

<ion-content class="home" padding>
  <div *ngIf="movie" class="selection">
    <ion-card>
        <ion-item>
            <ion-avatar item-left>
                <img src="path/to/image{{movie-poster}}"/>
            </ion-avatar>
            <ion-item-content class="movie-title-data">
                <h1>{{movie.title}}</h1>
                <p>{{movie.release_date}}</p>
            </ion-item-content>
        </ion-item>

        <ion-item>
            <icon document item-left></icon>
            <h2>Overview</h2>
            <p class="item-description">{{movie.overview}}</p>
        </ion-item>
        <ion-item>
            <icon bookmark item-left></icon>
            <h2>Average Vote</h2>
            <p>{{movie.vote_average}}</p>
        </ion-item>    
    </ion-card>
  </div>
</ion-content>

这是我得到的错误:

Unhandled Promise rejection: Template parse errors:
'ion-item-content' is not a known element:
1. If 'ion-item-content' is an Angular component, then verify that it is part of this module.
2. If 'ion-item-content' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("path/to/image{{movie-poster}}"/>
            </ion-avatar>
            [ERROR ->]<ion-item-content class="movie-title-data">
                <h1>{{movie.title}}</h1>
        "): MovieInfoPage@15:16

'icon' is not a known element:
1. If 'icon' is an Angular component, then verify that it is part of this module.

类似的错误会继续发生在所有元素上。

这是movie-info.ts

import {Component} from '@angular/core';
import {NavController, NavParams} from 'ionic-angular';

@Component({
  templateUrl: 'movie-info.html'
})

export class MovieInfoPage {

  movie: {};  

  constructor(private navController: NavController, private navParams: NavParams) {
    this.movie = navParams.get('movie');
  }   
}

1 个答案:

答案 0 :(得分:1)

对于模板错误:

因为它表明ion-item-content不是离子2中的有效标签。 我建议改用div。

ion-item component