Getting entire URL instead last key passing data Navparams

Hi everyone,

I’d like to send pass data from one page to another one, the problem is via NavParams im passing ENTIRE URL, and just what i want is the last parameter (a key), let me show you my code:

previous page:

  addVehicle(vehicle: Vehicle) {
    return this.vehicleListRef.push(vehicle)
                              .then(newVehicleDetails => this.navCtrl
                              .setRoot(HomePage, {newVehicleParams: newVehicleDetails}));
  }

next page:
this.newVehicleParams = this.params.get('newVehicleParams');

I’m getting https://XXXXXXXXXXXXXXXXX.firebaseio.com/XXXXX/-LX06l5lWHATSIaQVn9qW instead ‘-LX06l5lWHATSIaQVn9qW’, How could I take just the end of this URL? Thank you so much

Just navParams.data.newVehicleParams will solve it

Error: Uncaught (in promise): Error: Reference.child failed: First argument was an invalid path = “undefined”. Paths must be non-empty strings and can’t contain “.”, “#”, “$”, “[”, or “]”
Doesn’t work

Still shows entire URL…

Is this the result you got?

yes

  itemRef: firebase.database.Reference = fb.database().ref('/XXXXXX')
                                                      .child('this.navParams.data.newVehicleParams');

add the code i showed you on the next page not inside firebase

I did it, but its not working…

itemRef: firebase.database.Reference = fb.database().ref(this.params.data.newVehicleParams);

Finally its resolved, thanks for your help!

1 Like

Great…I am glad you got a fix. Weldone

1 Like