Getting the data from the list to an AlertController

Hai friends. I am new to Ionic development and I’m trying to implement an ecommerce app. So I have a list of items wrapped around *ngFor and I implemented ‘onLongClick()’ function which triggers an AlertControllerlist

onLongClick() function:

In the ‘onLongClick()’ when add button is clicked i want to get the 4 input fields plus the details of the item which i’m pressing, to be able to save to storage in the application.

I am having no luck in getting the selected item to the onLongClick function (from there i can use all the required data to be able to save to local storage). I am having trouble figuring out which parameters or data types I should pass in the function. please help.

You should be able to do this in your template:


Then in your controller:
onLongClick(item: YourItemType)

So I altered my template, and the ‘item’ contains an array of values. In my controller I tried to put onLongClick(item : array[])
this does not seem correct as I’m getting error in the editor itself. Please correct me

If item represents an array, how are you able to do: item.image, item.price, and in your template?

Would it be possible to see your data layout?

Hello @sam1408, can you please share the result of console.log(data)?

actually I solved it…I only needed to pass ‘item’ to the function ie, onLongClick(item) and I was able to retrieve the items in the function.


I passed 1 in every field and this is the log data: