Skip to content

Instantly share code, notes, and snippets.

@danic85
Last active November 23, 2016 13:40
Show Gist options
  • Save danic85/de627813450c9b5a8b176c11c6b4e0e6 to your computer and use it in GitHub Desktop.
Save danic85/de627813450c9b5a8b176c11c6b4e0e6 to your computer and use it in GitHub Desktop.
Lightning Select component markup with select inside iteration.
<aura:attribute name="selectOptions" type="object[]" description="A list of objects with value (ID) and text (label) attributes"/>
<aura:attribute name="selectedOption" type="ID" default="" description="The value of the selected option"/>
<lightning:select name="selectName" label="My Select" value="{!v.selectedOption}" onchange="{!c.doSomething}" required="true">
<aura:iteration items="{!v.selectOptions}" var="option">
<option value="{!option.value}" selected="{!if(v.selectedOption==option.value,'selected','')}">{!option.text}</option>
</aura:iteration>
</lightning:select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment