Getting entire URL instead last key passing data Navparams

#1

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

#2

Just navParams.data.newVehicleParams will solve it

#3

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…

#4

Is this the result you got?

#5

yes

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

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

#7

I did it, but its not working…

#8

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

Finally its resolved, thanks for your help!

1 Like
#9

Great…I am glad you got a fix. Weldone

1 Like