I'm trying to set an attribute inside the init method as described here.


<aura:component implements="flexipage:availableForAllPageTypes" access="global" >

    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

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

     {!v.canCreateRecord} <!-- outputs - false -->



    doInit: function(cmp){    
        cmp.set("v.CanCreateRecord",  true );                        

When I output {!v.CanCreateRecord} inside the view, I get the default value of 'false'.

According to the documentation, the attribute should be set inside the init function before it is rendered. However, it's not happening in my case. What could I be missing?


lightning is case sensitive so you need to set your attribute name as defined in component

    doInit: function(cmp){    
        cmp.set("v.canCreateRecord",  true );  //c is small here                      
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.