Passing Data Between Pages in Ionic
Why Stack Overflow recommends it
Stack Overflow users link it when answering how to pass data between pages or components in Ionic 2 and 3, since it walks through the main approaches in one place.
Recommended by 2 people across 2 different months, 2017 to 2017.
What it is
A 21-minute tutorial by Joshua Morony covering several methods for sharing data between pages in an Ionic 2 app, including navigation parameters and shared providers. It accompanies a blog post on the same topic and is part of his Ionic tutorial series.
What people said
Recommends Uniphonic · 2017-04 · Stack Overflow · on “In Ionic 2, how to pass attribute data between two components?”
There are a few different ways to pass data between pages in Ionic, which are covered in this video: [this video] For brevity, I'll only cover one of those ways here: if it's something you want to persist between multiple pages you might do that via an Ionic 2 Provider. You can generate a provider in the CLI: ionic g provider DemoProvider It will generate a provider which you can add variables to, like this: import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; import 'rxjs/add/operator/map'; /* Generated class for the DemoProvider provider. See [LINK] for more info on providers and Angular 2 DI. */ @Injectable() export class DemoProvider { mySharedVariable: String = "
Recommends JGFMK · 2017-07 · Stack Overflow · on “Can't Import ViewController into Provider in Ionic 2”
[LINK] Although it's Ionic2, this video should help you [this video] - Joshua Morony has a lot of useful videos when you are starting out with Ionic.
Cites cdh429 · 2017-11 · Stack Overflow · on “Ionic 2/3: Passing data to next page by ID”
I'm new to Ionic but essentially I'm looking to pass data from one screen to another, based on the ID. In my "reference.ts" folder I have the following code.. goToReference1(){ let id = document.getElementById("1") if(id = 1) { referenceField1: this.referenceList.referenceField1 this.navCtrl.push(ReferencePage,referenceField1); } else { console.log("nahhh") } }; In my levels.ts folder (the page linking to the data) I have.... ionViewDidLoad() { this.navParams.get("referenceField1") console.log(this.navParams.get("referenceField1")) } I wasn't sure if there was an easier way to pass and call this data based on the ID. I'm having a hard time displaying it on the next page. I've seen this tutor