I have been developing a basic lightning component to return all the names of my custom object "competitor" but am being thrown this error?
Assertion Failed!: Unable to get value for key 'competitor__c.Name'.
No value provider was found for 'competitor__c'. : false Failing
descriptor: {aura$iteration$controller$itemsChange}
Personally I cant see anything wrong with my approach so if someone else could give me some advice I would really appreciate it.
Thanks
CompetitorListController.apxc
public with sharing class CompetitorListController {
@AuraEnabled
public static List<Competitor__c> findAll() {
return [SELECT id, name FROM Competitor__c LIMIT 50];
}
}
CompetitorListController.cmp
<aura:component controller="CompetitorListController">
<aura:attribute name="competitors__c" type="competitor__c[]"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:handler event="c:SearchKeyChange" action="{!c.searchKeyChange}"/>
<ul>
<aura:iteration items="{!v.competitors__c}" var="competitor">
<li>
<a href="{! '#/sObject/' + competitor__c.Id + '/view'}">
<p>COMPETITORS GO HERE</p>
<p>{!competitor__c.Name}</p>
</a>
</li>
</aura:iteration>
</ul>
</aura:component>
CompetitorListController.js
({
doInit : function(component, event) {
var action = component.get("c.findAll");
action.setCallback(this, function(a) {
component.set("v.competitors__c", a.getReturnValue());
});
$A.enqueueAction(action);
},
searchKeyChange: function(component, event) {
var searchKey = event.getParam("searchKey");
var action = component.get("c.findComp");
action.setParams({
"searchKey": searchKey
});
action.setCallback(this, function(a) {
component.set("v.competitors__c", a.getReturnValue());
});
$A.enqueueAction(action);
}
})
Best Answer
As discussed in comments, you should be using competitor instead of competitor__c from var="competitor".
Another situation in which this same error comes, when you forget to put the "v" i.e value provider to the key.
In my case, it key should be {!v.progRecord.Start_Date__c}