How to set default value in picklist in Lightning Component in Salesforce?

Lightning Component:

<aura:component access="global">
    <ui:inputSelect aura:Id="makeId" multiple="false" label="Select Make">
        <ui:inputSelectOption label="Acura" text="acura" value="true"/>
        <ui:inputSelectOption label="Audi" text="Audi"/>
        <ui:inputSelectOption label="BMW" text="bmw"/>
        <ui:inputSelectOption label="Honda" text="honda"/>
        <ui:inputSelectOption label="Hyundai" text="hyundai"/>
        <ui:inputSelectOption label="Mercedes Benz" text="merc"/>
        <ui:inputSelectOption label="Nissan" text="nissan"/>
    <ui:button label="Find Vehicles" press="{!c.findVehicles}"/>

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

Lightning Component Controller:

findVehicles : function(component, event, helper) {


When Find Vehicles button is clicked, selected value will be alerted on the screen.

No comments:

Post a Comment