function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vinny rvinny r 

lightning component attribute is not set

Hi 

I am using the below code to set the component attribute in the init event. The server controller is returning the values, which I am assigning to the component attribute. But the value is not getting set. Can you please help.
 
({
    doInit:function(component,event,helper){
    console.log('start of init method');
    var options = component.get("v.options");
    options.push({'label':'Pleasure Boat','value':'PB'});
	var action = component.get("c.getBoatType");
    action.setCallback(this,function(response){
                       var state = response.getState(); 
                       if(state == "SUCCESS")
                       {
                           var resp = response.getReturnValue();
                           console.log("length of array " + resp.length);
                           component.set("v.boatType",resp);
                           var bt = component.get("v.boattype"); 
                           console.log('BT ' + bt.length);
                        }
        				else
                        {
                            console.log("Failed with state " + state);
                        }
    					});
	$A.enqueueAction(action);
}
})

User-added image

Thanks
Vinodh.
Best Answer chosen by vinny r
vinny rvinny r
I used v.boatType instead of v.boattype. Using the correct case for the attribute name resolved the issue.

component.set("v.boatType",resp);