I am unable to get selected value on change of picklist value in lightning Component. Below is my controller js and component.

<aura:component implements="flexipage:availableForAllPageTypes" access="global">
    <ltng:require styles="{!$Resource.slds232 + '/assets/styles/salesforce-
    <aura:attribute name="mySelectedText" type="String" default="some string"/>
    <aura:attribute name="contactLevel" type="String[]" default="Primary 
      Contact, Secondary Contact, Other" />
    <aura:handler name="init" value="{!this}" action="{!c.onSelectChange}"/> 
      <ui:inputSelect aura:id="levels" label="Contact Levels" change="
        <aura:iteration items="{!v.contactLevel}" var="level">
             <ui:inputSelectOption text="{!level}" label="{!level}"/>


   onSelectChange : function(component, event, helper) {
    var selected = component.find("levels").get("v.value");
  • 1
    I think you are missing closing '}' of onSelectChange method in Javascript controller – Ajay Prakash Dubey Oct 15 '17 at 8:53
  • If you are developing from Developer Console, You must get an error while saving your code. Winter 18 upgrade helping us in this syntax checks. For now, add the missing '}' in controller and check. – brahmaji tammana Oct 15 '17 at 12:37
  • I missed here but I have already added in my code. So am still getting that error – AnkushSalesforce Oct 15 '17 at 16:30
  • 1
    what if you change the init handler to some other controller. I am assuming this could be a timing issue where the init method calls the onSelectChange before the inputselect renders on the page. – Rao Oct 16 '17 at 15:50
  • Hi You mean to say I should write this code in a helper and call the helper from controller? – AnkushSalesforce Oct 17 '17 at 4:09

I figured out myself that i was adding my controller to other component.

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.