How to send parameters between pages with Nav Params in Ionic?

113 Views Asked by At

When I try to send data from one page to another, it does not detect anything.

This is my data model:

export interface rutaModel{

restaurante:string;
sede:string;

}

this is the function that push the navparams:

anyobjects:

 
  item: rutaModel = {
    restaurante:'',
    sede:''
}

  objruta:rutaModel;

function that send the navparams:

abrirqrsacanner()
  {
    const prompt = this.alertCtrl.create({
      title: 'Acceder a info del restaurante',
      message: "Se añade arreglo que contiene el id del restaurante y de la sede",
      inputs: [
        {
          name: 'Arreglo',
          placeholder: 'Arreglo'
        },
      ],
      buttons: [
        {
          text: 'Cancelar',
          handler: data => {
          }
        },
        {
          text: 'Continuar',
          handler: data => {

            
              this.abrirrestaurante(data.Arreglo);
            
            
            
            
          }
        }
      ]
    });
    prompt.present();
      
  }


  abrirrestaurante(Array:string){

    var Arreglo=Array.split(",")
    var idrestaurante=Arreglo[0];
    var idsede=Arreglo[1];
    this.item.restaurante=idrestaurante;
    this.item.sede=idsede;
    this.objruta=this.item;
    this.navCtrl.push(EscanerqrPage,this.objruta);
    
  }

this is the class that receive the params:

console.log(this.navParams.get('objruta'));
console.log(this.objruta);

thanks for your help!

0

There are 0 best solutions below