這是movie-info.html
我的代碼:Ionic2未處理的承諾拒絕:模板解析錯誤:「離子項目內容」是不是一個已知的元素:錯誤
<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>
"): [email protected]: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');
}
}
所以你的'MovieListPage'沒有選擇器? – echonax
@echonax我不明白你的意思。這是我第一次使用Ionic2。 :) –
在您的'@ Component'註釋裏'templateUrl'和'providers'是,你需要有一個'selector'來引用組件作爲一個元素。但我對離子的瞭解不多,可能會有所不同。 'MovieInfoPage'和'MovieListPage'之間的關係是什麼? – echonax