[SalesForce] Problem in a picklist – inputSelect – Lightning component

I have a picklist in a lightning component. This picklist is displaying 12 values (from 1 to 12)

Here is the picklist :

<aura:attribute name="mois_exp" type="Integer" />
<aura:attribute name="mois_values" type="Integer[]"/>

<ui:inputSelect aura:id="mois_exp" class="slds-input" value="{!v.mois_exp}">
   <aura:iteration items="{!v.mois_values}" var="val">
       <ui:inputSelectOption text="{!val}" />
   </aura:iteration>
</ui:inputSelect>

The javascript controller :

doInit : function(component, event, helper) {
    var action = component.get("c.getListOfMonths");

    //get the values of the month picklist
    action.setCallback(this, function(a) {
        var result = a.getReturnValue();
        component.set('v.mois_values', result);
    });

    $A.enqueueAction(action);
},

And the apex class getListOfMonths :

@AuraEnabled
public static List<Integer> getListOfMonths(){
    List<Integer> months = new List<Integer>();

    for(Integer i = 1; i < 13; i++){
        months.add(i);
    }
    return months;
}

The problem is that when I click the picklist to show the values, I can see the 12 value but not select one. The only value I can "select" is the first value.

How can I make the other value availables to be selected ?

Best Answer

I resolve my problem by using lightning:select tag :

<lightning:select aura:id="mois_exp" class="slds-form-element__control" name="mois_exp" label="Mois d'expiration" onchange="{!c.changeMonth}">
    <option value="" text=""></option>
    <aura:iteration items="{!v.mois_values}" var="val">
              <option value="{!val}" text="{!val}"></option>
    </aura:iteration>
</lightning:select>
Related Topic