I am new to Lightning and i am trying some basic things. I am getting this error in Preview. Pls help.
"Error during init : helper.method is not a function"
Apex Class
public class contactAura {
@AuraEnabled
public static List<Contact> getAllContacts()
{
return [select id, name from Contact limit 5];
}
}
component
<aura:component controller="contactAura" >
<aura:attribute name="contactRows" type="Object[]"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<div class="container">
<p>
<b> List of Contacts </b>
</p>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th><strong> Id </strong></th>
<th> <strong> Name </strong> </th>
</tr>
</thead>
<tbody>
<aura:iteration var="cell" items="{!v.contactRows}">
<tr>
<td> <a href="{! '/'+cell.Id}"> {!cell.Id} </a> </td>
<td> {!cell.Name} </td>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
</aura:component>
Component Controller
({
doInit : function(component, event, helper) {
helper.getAllContacts(component);
}
})
Component Helper
({
getAllContacts: function(component, event, helper){
var action = component.get("c.getAllContacts");
action.setCallback(this, function(a){
component.set("v.contactRows", a.getReturnvalue());
})
$A.enqueueAction(action);
}
})
Application
<aura:application >
<link href='/resource/bootstrap/' rel="stylesheet"/>
<c:AllContactsComp />
</aura:application>