I have an Ionic 2 project with a blank template containing a page that displays a list. Upon clicking on an item in the list, the user should be able to view more details about that specific item. Below are the files related to the list:
list.html:
<ion-navbar *navbar>
<ion-title>list</ion-title>
</ion-navbar>
<ion-content padding class="list">
<ion-list>
<ion-item *ngFor="let item of items" (click)="viewItem(item)">{{item.title}}</ion-item>
</ion-list>
</ion-content>
list.js:
import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {ItemDetailPage} from '../item-detail/item-detail';
@Component({
templateUrl: 'build/pages/list/list.html',
})
export class ListPage {
static get parameters() {
return [[NavController]];
}
constructor(nav) {
this.nav = nav;
this.items = [
{title: 'Hi1', description: 'whats up?'},
{title: 'Hi2', description: 'whats up?'},
{title: 'Hi3', description: 'whats up?'}
];
}
viewItem(){
this.nav.push(ItemDetailPage, {
item: item
});
}
}
In addition, here are the files for the detail view:
detail-view.html:
<ion-navbar *navbar>
<ion-title>{{title}}</ion-title>
</ion-navbar>
<ion-content padding class="item-detail">
<ion-card>
<ion-card-content>
{{description}}
</ion-card-content>
</ion-card>
</ion-content>
detail-view.js:
import {Component} from '@angular/core';
import {NavController, NavParams} from 'ionic-angular';
@Component({
templateUrl: 'build/pages/item-detail/item-detail.html',
})
export class ItemDetailPage {
static get parameters() {
return [[NavController]];
}
constructor(navParams: NavParams) {
this.navParams = navParams;
this.title = this.navParams.get('item').title;
this.description = this.navParams.get('item').description;
}
}
Upon running "ionic serve," I encountered the following error message:
SyntaxError: C:/.../app/pages/item-detail/item-detail.js: Unexpected token (18:23) while parsing file: ...
It seems like the way the constructor is set up in the detail view file may not be compatible with the current version of Ionic Framework (2.0.0-beta.8). Unfortunately, I couldn't find any relevant information or solutions online. Any guidance would be greatly appreciated.