I'm trying to implement a helper method in a Lightning component, but the error that comes up is:
"This page has an error. You might just need to refresh it. Error during init [Action failed: c:EmployerList$controller$doInit > [helper.getEmployerSubset_Lightning is not a function]]"
Here is my component:
<aura:component controller="EmployerListController" implements="forceCommunity:availableForAllPageTypes">
<aura:attribute name="pageIndex" type="Integer" default="0"/>
<aura:attribute name="serverData" type="EmployerListController"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:iteration items="{!v.serverData.accountSubset}" var="employer">
<c:EmployerListCell employer="{!employer}" />
</aura:iteration><br/>
<br/>
Page {!v.pageIndex+1} of {!v.serverData.numberOfPages}
<!--<lightning:button value="First" onClick="{!firstPage}"/>
<lightning:button value="Previous" onClick="{!previousPage}"/>
<lightning:button value="Next" onClick="{!nextPage}"/>
<lightning:button value="Last" onClick="{!lastPage}"/>-->
</aura:component>
And my controller init method:
({
doInit : function(component, helper){
console.log('getEmployerSubset_Lightning.entry');
helper.getEmployerSubset_Lightning(component);
}
})
And my helper method:
getEmployerSubset_Lightning : function(component) {
var getServerDataAction = component.get("c.getEmployerListController");
getServerDataAction.setParams({
"pageIndex": 0
});
getServerDataAction.setCallback(this, function(response) {
var state = response.getState();
if (component.isValid() && state === "SUCCESS") {
//Update account list
component.set("v.serverData", response.getReturnValue());
console.log(component.get("v.serverData.numberOfPages"));
console.log(component.get("v.serverData.accountSubset"));
}
else {
alert("error!");
}
});
console.log('getEmployerSubset_Lightning.enqueueAction');
$A.enqueueAction(getServerDataAction);
}
I can't for the life of me figure out why this wouldn't be working.