とコンポーネントにデータを取得するが、それは私が、角度は、別のページに1ページからデータを取得する方法入力
はTypeErrorに新しいショーのエラーです:[{{mediaItem.id}に未定義のプロパティ「ID」を読み込めません} MediaItemComponent
<section>
<media-item [mediaItem]="firstMediaItem"></media-item>
</section>
first.ts
データfirst.htmlを取得する方法を
で
import {Component} from 'angular2/core';
import {MediaItemComponent} from './secound';
@Component({
selector: 'media-tracker-app',
directives: [MediaItemComponent],
templateUrl: 'app/app.component.html',
styleUrls: ['app/app.component.css']
})
export class AppComponent {
firstMediaItem = {
id: 1,
name: "Firebug",
medium: "Series",
category: "Science Fiction",
year: 2010,
watchedOn: 1294166565384,
isFavorite: false
};
}
secound.html
<h2>{{ mediaItem.id }}</h2>
<div>Watched on {{ mediaItem.watchedOn }}</div>
<div>{{ mediaItem.category }}</div>
<div>{{ mediaItem.year }}</div>
secound.ts
import {Component, Input} from 'angular2/core';
@Component({
selector: 'media-item',
templateUrl: 'app/media-item.component.html',
styleUrls: ['app/media-item.component.css']
})
export class MediaItemComponent {
@Input('mediaItemToWatch') mediaItem;
}