Activity Forums Salesforce® Discussions How can we use collections in lightning in salesforce?

  • MOHIT

    Member
    June 19, 2020 at 3:12 pm

    <aura:attribute name="numbers" type="List"/>
    <lightning:button onclick="{!c.getNumbers}" label="Display Numbers" />
    <aura:iteration var="num" items="{!v.numbers}">
    {!num.value}
    </aura:iteration>

    /** Client-side Controller **/
    ({
    getNumbers: function(component, event, helper) {
    var numbers = [];
    for (var i = 0; i < 20; i++) {
    numbers.push({
    value: i
    });
    }
    component.set("v.numbers", numbers);
    }
    })

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos