Created
September 27, 2018 17:21
-
-
Save Sunil02kumar/a6e11ce4b90c0ca21d782ddca7bac311 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <aura:application extends="force:slds"> | |
| <!-- extends "force:slds" interface so that SLDS will be imported in lightning component--> | |
| <c:SK_LightningBasicsSSC/> | |
| </aura:application> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <aura:component controller="SK_LightningBasicsSSController"> | |
| <aura:attribute name="ltngAccountList" type="List"/> | |
| <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> | |
| <table class="slds-table"> | |
| <tr> | |
| <th>Account Name</th> | |
| <th>Account Type</th> | |
| </tr> | |
| <aura:iteration items="{!v.ltngAccountList}" var="Acc"> | |
| <tr> | |
| <td>{!Acc.Name}</td> | |
| <td>{!Acc.Type}</td> | |
| </tr> | |
| </aura:iteration> | |
| </table> | |
| </aura:component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ({ | |
| doInit : function(component, event, helper) { | |
| var actionName= component.get("c.findRecentAccounts"); | |
| actionName.setCallback(this, function(response) { | |
| var state = response.getState(); | |
| if (state === "SUCCESS") { | |
| var apexResponse=response.getReturnValue(); | |
| //set response to attribute value | |
| console.log('***'+JSON.stringify(apexResponse)); | |
| component.set("v.ltngAccountList",apexResponse); | |
| }else if(state === "ERROR"){ | |
| var errors = response.getError(); | |
| console.error(errors); | |
| alert('Problem with connection. Contact your system administrator.'); | |
| } | |
| }); | |
| $A.enqueueAction(actionName); | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Public class SK_LightningBasicsSSController { | |
| @AuraEnabled | |
| public static List<Account> findRecentAccounts(){ | |
| return [select id,name,type from Account | |
| order by LastmodifiedDate DESC Limit 10]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment