How to create picklist in Lightning Component in Salesforce?

Lightning Component:- PicklistLightningComp

<aura:component>
<ui:inputSelect aura:Id=”picklistId” multiple=”false” label=”Select Details”>
<ui:inputSelectOption label=”-Select–” text=”Select” value=”false”/>
<ui:inputSelectOption label=”A” text=”A” value=”true”/>
<ui:inputSelectOption label=”B” text=”B”/>
<ui:inputSelectOption label=”C” text=”C” />
<ui:inputSelectOption label=”D” text=”D”/>
</ui:inputSelect><br/><br/>
<ui:button label=”Find Value” press=”{!c.findValues}”/>
</aura:component>

here value=”true” is used to set the default value.

Lightning Component Controller:-

({
findValues : function(component, event, helper)
{

var pickVal=component.find(“picklistId”).get(“v.value”);
alert(‘Selected Values is : “+pickVal);
}
})

Lightning Application:-
<aura:application extends=”force:slds” >
<c:PicklistLightningComp/>
</aura:application>

Leave a Reply