You need to sign in to do that
Don't have an account?
Nethra Raghupathy
Lightning:select takes dynamic values from controller
Hi,
I'm trying to have dynamic dropdown list but I'm not sure how to communicate with controller. It shows error as "Invalid attribute "name": Source" in aura:attribute and aura:handler
UserDetails.cmp:
UserDetailsController.js:
I'm trying to have dynamic dropdown list but I'm not sure how to communicate with controller. It shows error as "Invalid attribute "name": Source" in aura:attribute and aura:handler
UserDetails.cmp:
<aura:component implements="force:appHostable" > <lightning:layout class="slds-page-header slds-page-header--object-home"> <lightning:layoutItem> <lightning:icon iconName="standard:scan_card" alternativeText="Add User"/> </lightning:layoutItem> <lightning:layoutItem padding="horizontal-small"> <div class="page-section page-header"> <h1 class="slds-text-heading--label">Add User</h1> <h2 class="slds-text-heading--medium">Add User</h2> </div> </lightning:layoutItem> </lightning:layout> <lightning:layout> <lightning:layoutItem padding="around-small" size="6"> <div aria-labelledby="newexpenseform"> <!-- BOXED AREA --> <fieldset class="slds-box slds-theme--default slds-container--small"> <legend id="newexpenseform" class="slds-text-heading--small slds-p-vertical--medium"> Add User </legend> <form class="slds-form--stacked"> <aura:attribute name="users" type="List" /> <aura:attribute name="selectedUser" type="String" /> <aura:handler name="init" value="{!this}" action="{!c.loadOptions}" /> <lightning:select name="mySelect1" label="Select Role:" aura:id="mySelect1" value="{!v.selectedValue}"> <aura:iteration items="{!v.options}" var="item"> <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/> </aura:iteration> </lightning:select> </form> </fieldset> </div> </lightning:layoutItem> </lightning:layout> </aura:component>
UserDetailsController.js:
({ loadOptions: function (component, event, helper) { var roles = [ { value: "Manager", label: "Manager" }, { value: "team", label: "team" } ]; component.set("v.options", roles); var users = [ { value: "x", label: "x" }, { value: "y", label: "y" }, { Value: "z" , label: "z"} ]; component.set("v.users", users); } })
You have to move attributes to top of the page with the 'Option' attribute. Please check below code,
Best regards
All Answers
You have to move attributes to top of the page with the 'Option' attribute. Please check below code,
Best regards