Monday, February 13, 2017

What is in lightning component and how to use in lightning components?.

What is <aura:iteration> in lightning component and how to use <aura:iteration> in lightning components?.


aura:iteration iterates over a collection of items and renders the body of the tag for each item.

Data changes in the collection are rerendered automatically on the page. aura:iteration supports iterations containing components that have server-side dependencies or that can be created exclusively on the client-side.


Example Using Data from a Server-Side Controller

This example shows a dynamic iteration that displays data from a standard Opportunity object when user clicks on the button.

Apex Class:

public with sharing class OpporutnityLightningController {
   
    @AuraEnabled
    public static List<Opportunity> getOpportunities(){
        List<Opportunity> opplist = [select id,Name from opportunity];
        return opplist;
    }

}

Lightning Opportunity Component : 



Opportunity Component Controller.JS




Opportunity component App:





Output : 



In this example i am giving basic idea of how to use <aura:iteration> with apex class.

for more details you can refer salesforce documentation.







2 comments:

Post a Comment

 
| ,