RPeraltaJr
8/3/2017 - 4:11 PM

Pass Data from One Page to Another (source: from 'Ionic-Feed' project)

Pass Data from One Page to Another (source: from 'Ionic-Feed' project)

...
import { NavController, NavParams } from 'ionic-angular'; // <-- NavParams needed to pass data between pages
...
...

@Component({
  selector: 'page-detail',
  templateUrl: 'detail.html',
})
export class DetailPage {

  // Get data passed from HomePage
  key: string = this.navParams.get('$key');
  title: string = this.navParams.get('title');
  body: string = this.navParams.get('body');
  timestamp: string = this.navParams.get('timestamp');
  authorId: string = this.navParams.get('authorId');
  authorName: string = this.navParams.get('authorName');
  authorEmail: string = this.navParams.get('authorEmail');
  authorPhoto: string = this.navParams.get('authorPhoto');
  
  constructor(public navCtrl: NavController, public navParams: NavParams) {
    // Listen for new data on this subject
    ...
    ...
  }
}