export class HomePage {
items = [
{
title: 'Courgette daikon',
content: 'Parsley amaranth tigernut silver beet maize fennel spinach. Ricebean black-eyed pea maize scallion green bean spinach cabbage jícama bell pepper carrot onion corn plantain garbanzo. Sierra leone bologi komatsuna celery peanut swiss chard silver beet squash dandelion maize chicory burdock tatsoi dulse radish wakame beetroot.',
icon: 'calendar',
time: {subtitle: '4/16/2013', title: '21:30'}
},
{
title: 'Courgette daikon',
content: 'Parsley amaranth tigernut silver beet maize fennel spinach. Ricebean black-eyed pea maize scallion green bean spinach cabbage jícama bell pepper carrot onion corn plantain garbanzo. Sierra leone bologi komatsuna celery peanut swiss chard silver beet squash dandelion maize chicory burdock tatsoi dulse radish wakame beetroot.',
icon: 'calendar',
time: {subtitle: 'January', title: '29'}
},
{
title: 'Courgette daikon',
content: 'Parsley amaranth tigernut silver beet maize fennel spinach. Ricebean black-eyed pea maize scallion green bean spinach cabbage jícama bell pepper carrot onion corn plantain garbanzo. Sierra leone bologi komatsuna celery peanut swiss chard silver beet squash dandelion maize chicory burdock tatsoi dulse radish wakame beetroot.',
icon: 'calendar',
time: {title: 'Short Text'}
}
]
constructor(public navCtrl: NavController) {
}
}
Insted에 JSON을 가져 오는 방법, 난과 이온 성 3을 읽으려고이온 타임 라인 프로젝트를 수동으로 입력 JSON의
{"items":[{"agendaid":"1","title":"Avreise Medina","content":"Avreise til Medina er klokken 18:30, det er oppm\u00f8te p\u00e5 flyplassen 3 timer f\u00f8r avreise. Alle m\u00e5 selv komme tidsnok til \u00e5 f\u00e5 sitte sammen andre i familien. Det er kun lov til \u00e5 ha med seg 30 kg baggasje og 7 kg h\u00e5ndbaggasje","icon":"plane","TimeTitle":"21.12.2017","TimeSubtitle":"18:30","ExecuteTime":"2017-12-21 18:30:00"},{"agendaid":"2","title":"test","content":"test","icon":"test","TimeTitle":"test","TimeSubtitle":"test","ExecuteTime":"2017-11-22 17:26:23"}]}
임있는 JSON 파일에서이 문제를 가져올 것 이 코드
url: string = 'http://backend.mishkaat.no/app/agenda.php';
items: any = [];
constructor(public navCtrl: NavController, public navParams: NavParams,private http: Http) {}
ionViewDidEnter() {
this.http.get(this.url)
.map(res => res.json())
.subscribe(data => {
// we've got back the raw data, now generate the core schedule data
// and save the data for later reference
this.items = data;
});
}
그러나이 오류가 점점 :
Error: Error trying to diff '[object Object]'. Only arrays and iterables are allowed
at DefaultIterableDiffer.diff (http://localhost:8100/build/vendor.js:7695:19)
at NgForOf.ngDoCheck (http://localhost:8100/build/vendor.js:43776:57)
at checkAndUpdateDirectiveInline (http://localhost:8100/build/vendor.js:12451:19)
at checkAndUpdateNodeInline (http://localhost:8100/build/vendor.js:13951:20)
at checkAndUpdateNode (http://localhost:8100/build/vendor.js:13894:16)
at debugCheckAndUpdateNode (http://localhost:8100/build/vendor.js:14766:76)
at debugCheckDirectivesFn (http://localhost:8100/build/vendor.js:14707:13)
at Object.eval [as updateDirectives] (ng:///AppModule/AgendaPage.ngfactory.js:99:5)
at Object.debugUpdateDirectives [as updateDirectives] (http://localhost:8100/build/vendor.js:14692:21)
at checkAndUpdateView (http://localhost:8100/build/vendor.js:13861:14)
을
는 HTML 파일
<timeline endIcon="call">
<timeline-item *ngFor="let item of items">
<timeline-time [time]="item.time"></timeline-time>
<ion-icon [name]="item.icon"></ion-icon>
<ion-card>
<ion-card-header>
{{item.title}}
</ion-card-header>
<ion-card-content>
{{item.content}}
</ion-card-content>
</ion-card>
</timeline-item>
</timeline>
어떤 도움에를 표시 할 때?
이 코드를 확인하십시오. 'this.items = data.items;' –
감사합니다! 그것을 해결했습니다! –
새로운 퀘스트가 도착했습니다. –