0

I am trying to display some text on Page by using Lighting componets.i am not getting that text on click on check box Below is my code .Let mek nwo where is my code wrong.

A>Component attribute define

<aura:attribute name="CheckBoxValue" type="Boolean" default="false"/>

Lightning tag with aura id defined in it

<lightning:input aura:id="checkBoxAM" label="Are you new to this course" name="HaveYouTakenCourseBefore" type="checkbox" onchange="{!c.onClickCheckBox}"/>

B>This is my Aura if conditiontag along with text to be displayed

<aura:if isTrue="{!v.CheckBoxValue}">
        <br/>
            Hello  You have checked this box
 </aura:if>

C>THis is my JS function in Controller

onClickCheckBox: function(component,event,helper) {

    // accesing the value of attribute HaveYouTakenCourseBefore;
    // Call function defined in helper;
    // hlpr.<Function Name in helper>
    console.log("This text is from helper function");
    helper.onClickCheckBoxhelper(component);

        }

D>This is my FUnction defined in helper

onClickCheckBoxhelper : function(component) {

        //body of helper resourse
        // define logic of your function
        console.log("This text is from helper function");
        var checkBoxValue = component.find("checkBoxAM").get("v.checked");
        component.set("v.checkBoxAM",checkBoxValue);

E> Calling this Component in my Lightning App

PFA screen shot enter image description here

1
  • What did you do to my question ? What is edited not getting
    – AM_SFDC
    Apr 21, 2020 at 14:04

1 Answer 1

0

Hi I see that the attribute you're validating on the IF is CheckBoxValue but the one your seeting on your helper method is checkBoxAM.

My recomendation would be to modify the helper method to this:

component.set("v.CheckBoxValue",checkBoxValue);

1
  • No is nt working by changing that
    – AM_SFDC
    Apr 21, 2020 at 14:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .