ionic dropdown select issue

CraZyDroiD picture CraZyDroiD · Sep 23, 2014 · Viewed 11.9k times · Source

i'm new to ionic and i have this problem about ionic dropdown select component.I've implemented a dropdown and i want to display the option i selected in a label.How can i do this? at the moment i only can select a option and that's it. i want to show my selected option in a label.

enter image description here

Here i want to display the option i selected in "select your bank label".

This is how i implemented my dropdown select component

<label><h4><b>Bank Name*</b></h4></label>



 <div class="list">
        <div class="item item-input item-select">
            <div class="input-label">
                Select your Bank
            </div>
            <select>
                <option>Bank1</option>
                <option>Bank2</option>
                <option>Bank3</option>
            </select>
        </div>
    </div>

Answer

JakeSidSmith picture JakeSidSmith · Sep 23, 2014

Add a model to your select. This will create a variable on scope that you can use elsewhere.

<select ng-model="myVariable">

In your controller you can set a starting value.

$scope.myVariable = 'Hello, world!';

Then you can display this in your HTML like so.

<div>{{myVariable}}</div>

I suggest you do some reading into ionic framework and angular js documentation. :)