function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sakthidharan Ambayiramsakthidharan Ambayiram 

This page has an error. You might just need to refresh it. Error in $A.getCallback() [Component is not defined] Callback failed: apex://getAccountList/ACTION$getAllAccounts Failing descriptor: {c:AccList}

I am new to lightning . I am getting the below error

"This page has an error. You might just need to refresh it.
Error in $A.getCallback() [Component is not defined]
Callback failed: apex://getAccountList/ACTION$getAllAccounts
Failing descriptor: {c:AccList}"

My Code:
****************Apex class****************
public class getAccountList {
    @AuraEnabled
    public static List<Account> getAllAccounts(){
        return[select Id,Name,Type,Phone from Account ];
    }
     @AuraEnabled
    public static List<Account> getFilterAccounts(){
        return[select Id,Name,Type,Phone from Account where Type='Prospect'];
    }
}
************COMPONENT************************
<aura:component controller="getAccountList" >
    <aura:attribute name="AccList" type="List" />
    <aura:attribute name="PaginationList" type="Account[]" />
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    <aura:attribute name="Pagesize" type="Integer" default="10" />
    <aura:attribute name="Totalsize" type="Integer" />
    <tr><ui:inputSelect aura:id="records" >
        <ui:inputSelectOption text="10" value="10"/>
        <ui:inputSelectOption text="20" value="20"/>
        <ui:inputSelectOption text="30" value="30"/>
    </ui:inputSelect></tr>
    <table>
        <thead>
            <th>Id</th>
            <th>Name</th>
            <th>Phone</th>
            <th>Type</th>
        </thead>
     <tbody>
            <aura:iteration items="{! v.AccList}" var="Acc" >
                <tr>
                    <td>{! Acc.Id}</td>
                    <td>{! Acc.Name}</td>
                    <td>{! Acc.Phone}</td>
                    <td>{! Acc.Type}</td>
                    <td><c:Menu testRecord="{! Acc.Id}"/></td>
                </tr>
            </aura:iteration>
        </tbody>
    </table>
</aura:component>
********************Controller*******************
({
    doInit : function(component, event, helper){
        helper.callServerMethod(component,"c.getAllAccounts","v.AccList");    
       
    }

})
*******************Helper*****************************
({
    callServerMethod : function(component,methodName,attributeName) {
    var Pagesize = component.get("v.Pagesize");
    var methodRef = component.get(methodName);
        methodRef.setCallback(this,function(response){
            if(response.getState()=="SUCCESS"){
                component.set(attributeName,response.getReturnValue());
            }else{
                alert("Problem in method call");
            }
            Component.set("v.Totalsize",component.get(methodName).length);
            var PaginationList = [];
            for(var i=0;i<Pagesize;i++)
            {
                PaginationList.push(response.getReturnValue()[i]);
            }
            component.set("v.PaginationList",PaginationList);
        });
        $A.enqueueAction(methodRef);
    }    
})
Best Answer chosen by sakthidharan Ambayiram
Nayana KNayana K
Please change:
Component.set("v.Totalsize",component.get(methodName).length);
to 
component.set("v.Totalsize",component.get(methodName).length);

case sensitivity matters!
 

All Answers

Nayana KNayana K
Please change:
Component.set("v.Totalsize",component.get(methodName).length);
to 
component.set("v.Totalsize",component.get(methodName).length);

case sensitivity matters!
 
This was selected as the best answer
sakthidharan Ambayiramsakthidharan Ambayiram
Thanks a lot Nayana its working now.