You need to sign in to do that
Don't have an account?

I want to print the numbers on lightning component
Here is My code ::
Apex controller---
public class Numbers {
@AuraEnabled
public static void numbers (){
List<Integer> intlist = new List<Integer>();
for(Integer i=0; i<=100 ; i++){
intlist.add(i);
}
}
}
==================
component :
<aura:component controller="Numbers">
<aura:attribute name="Number" type ="Integer"/>
<aura:iteration items="{!Number}" var="x">
{!x}
</aura:iteration>
<aura:handler name="init" value="{!this}" action ="{!c.doInIt}"/>
</aura:component>
================================
client-side controller:
({
doInIt : function(component, event, helper) {
var action = component.get("c.numbers");
action.setCallback(this, function(response){
component.set("v.Number", response.getReturnValue());
});
$A.enqueueAction(action);
}
})
========
Apex controller---
public class Numbers {
@AuraEnabled
public static void numbers (){
List<Integer> intlist = new List<Integer>();
for(Integer i=0; i<=100 ; i++){
intlist.add(i);
}
}
}
==================
component :
<aura:component controller="Numbers">
<aura:attribute name="Number" type ="Integer"/>
<aura:iteration items="{!Number}" var="x">
{!x}
</aura:iteration>
<aura:handler name="init" value="{!this}" action ="{!c.doInIt}"/>
</aura:component>
================================
client-side controller:
({
doInIt : function(component, event, helper) {
var action = component.get("c.numbers");
action.setCallback(this, function(response){
component.set("v.Number", response.getReturnValue());
});
$A.enqueueAction(action);
}
})
========
You need to do These Changes
In apex class
in Component JSController
I hope this will help you
Regards
Ashif
I would accomplish this inside lightning component and avoid Server-side call like below:
Component code: Component controller: Hope it helps and mark answer correct so that it helps others.