Hey all, I’m stumped I’ve spent a to many hours trying to figure this one out.
I have a localstorage array which ngfor is looping through, each item has a click event to display a popover to enter more details, I want to pass the local item to the popover so I can than update the item onDismiss & before the user submits the form. I’ve tested it with a static array and it works fine but when ever I try and access the item data I can back undefined, I can’t figure it out any help would be great!
this is my function to call to create the popover.
//Show service detail on item click
presentService(ServiceDetail,event, data) {
let popover = this.popoverCtrl.create(ServiceSectionDetailPage, data, {cssClass: 'serviceItemDetail'});
popover.present({
ev: ServiceDetail
});
}
This is the item list that has the click and working data in it.
I found the answer after some head banging. Whatever is passed into the second param of the create method (in my case docs) is available with this.navParams.data. Hope someone else finds this useful.
Thanks for the tip, but I tried using get(), but kept getting undefined for some reason. That is what led me to just consoling this.navParams and seeing the data there, so that is what I went with. Based off my code above, this is exactly what I had
this.navParams.get(‘docs’).
Maybe I am missing something, but no luck with that. Also, you mind sharing why you prefer one over the other?
I figure since somebody bothered to define get(), they probably wouldn’t be too concerned about changing the underlying implementation (using data), so get() would be less likely to break out from under me. There was also a vaguely similar issue with forms a while back. Using form.get('control') in a template worked, but directly accessing the controls property with index signature (form.controls['control']) would subtly break.