When i pass data through navCtrl it show me the data as an object on next page

my question is after adding patient data and then passing that data as an object on the next page and then when I save that object in the database it gives me an error like this object(…) is not a function ionic, so how can I resolve that issue?

**Move data from Patient to Medicine Page then Medicine to Schedule **

patient:Patient;
export class AddPatientPage {
  AllPatient:any;
constructor(public navCtrl: NavController,
              private databasedata: DatabasedataProvider,
              public loadincontroller:LoadingController,public navParams: NavParams) {
this.patient=new Patient(this.id,this.name,this.doctor_name,this.hospital_clinic,this.date,'pending');
this.AllPatient=this.patient;
  }
patientadd() {
  
    this.navCtrl.push(MedicinedisplayPage, {patientdata: this.AllPatient});
}

MedicineDisplay.ts page

 patientdata:string;

  constructor(public navCtrl: NavController, public loadingcontroller:LoadingController,
              public medService: MedicineServicerProvider,
              public Alert:AlertController,public navParams: NavParams, public toast:ToastController) {
 
         this.patientdata=this.navParams.get("patientdata");
}

Medicinedisplay.html

 <div>
      <h5>Parameters passed:</h5>

      <pre style="background-color: #f8f8f8">selections: [
        {{patientdata}}
        ]</pre>

    </div>

Captureyyy

Hi, @FK2193
Here you have just declared AllPatient variable in AddPatientPage you have not assigned any value to it. So, I think that’s why on the next page it is not showing any data.

yeah its my mistake , i edit it.

Hi,
Have you seen what are you getting in MedicineDisplay page by doing console.log(this.patiendata)?
If you getting data in the console then after we understand how to display it in the HTML page.

it shows nothing :persevere:

Yes, it shows undefined in the console and one more thing is that as it is returning an object or array you can’t directly display it in HTML file.
Now what you can do is first, you need to check that the data this.AllPatient and this.Patient means console it which is passed from the AddPatientPage and check that it is showing any data there or not?
If it is showing undefined there also then this is not the problem of passing data from one page to another page.

thanks for replying me, it solved now :slight_smile:

1 Like