I have an iteration over the values of a picklist in a lightning component. It dynamically generates checkboxes for every value of this picklist.
I want to be able to use the value of this picklist to filter an array
When I apply this I get the error:
Action failed: c:checkboxFilter$controller$Techniek [opleidingen is not defined]
In this case Techniek is the fieldvalue on the object. How do I define a value of a field on an object
Here is my code Component
<aura:attribute name="opleidingen" type="Opleiding__c[]"/>
<aura:attribute name="fieldName" Description="API Name of Picklist Value" type="String" />
<aura:attribute name="objectName" Description="API Name of the Object" type="Opleiding__c[]" />
<aura:attribute name="checkboxValue" type="Boolean" default="true" />
<aura:attribute name="records" type="object[]" description="" access="private" />
<div style="width:100%" class="slds-align_absolute-left">
{!v.objectName}
<aura:iteration items="{!v.records}" var="item" indexVar="indx">
<ui:inputCheckbox aura:id="checkbox"
value="{!item.checkboxValue}"
text="{!item.fieldName}"
name="{!indx}"
label="{!item.fieldName}"
change="{!c.Techniek}"/> {#item.val}
</aura:iteration>
Javascript
component.set("v.alleOpleidingen");
var checkboxValue = event.getSource().get('v.value');// This is different in the documentation(Gianni).
if(checkboxValue == true){
console.log('Evaluates to true');
var result = opleidingen.filter(function(opl) {
return typeof opl.Categorie__c === "{!v.label}";
});
component.set("v.Evaluates to true",result);
}
else{
console.log('false');
I tried with JSON.stringify(opl.Categorie__c)
but this give the same error
c:checkboxFilter$controller$Techniek [action is not defined]
component.set("v.opleidingen");
You missed the second argument which should be the value you want to set to your variable. Also, the line:component.set("v.Evaluates to true",result);
can't work. – Martin Lezer Jan 31 '18 at 8:16