You need to sign in to do that
Don't have an account?
Mohammed zabi 6
Lightning component iteration selected value remove from object
Hi All,
I am new to lightning App in salesforce,
I had a problem with lightning components,
I am displaying an Array in lightning component using "aura:iteration"
In this i have a close icon next to Name like "SAMPLE X" when i click on Close icon that value need to remove from the javascript array in lightning component controller.
Please help on this
Thanks
I am new to lightning App in salesforce,
I had a problem with lightning components,
I am displaying an Array in lightning component using "aura:iteration"
In this i have a close icon next to Name like "SAMPLE X" when i click on Close icon that value need to remove from the javascript array in lightning component controller.
Please help on this
Thanks
Luckily the aura:iteration component has a super convenient, built-in attribute called indexVar. By leveraging indexVar I am able to pass the array index to the controller action, which can then use Array.prototype.splice() to remove an element from the list.
For example, consider the following aura:iteration element: I've intentionally included a ui:button and a standard HTML a (anchor) to show how to get the index value in both cases. The controller actions are shown below.
And helper.removeLead() is defined as follows:
II)If you are using a checkbox to remove an item from the array list see below:
I added a button in expenseList.cmp to handle removing of the expense item. Then, I created an event, deleteExpenseItem.evt, to capture and pass the removed item. Fire the event in expenseListController.js Handle the event in form.cmp. Add the handler to formController.js. Call your Apex controller to delete the expense item and update the view in formHelper.js. And don't forget to include the delete DML operation in ExpenseController.apxc.
Please mark this post as solved if it helps.
Best Regards,
Nagendra.P
Here is what I am trying to use:
<aura:iteration items="{!v.testData}" var="test" indexVar="i">
<a href="#" id="{!i}" onclick="{!c.showDetails}" class="slds-type-focus slds-truncate"> {!test.Name} </a>
</aura:iteration>
showTravellerDetails: function (component, event, helper) {
var self = this;
var index = event.target.dataset.index;
console.log(index);
}
Need Help.