I cannot find further information in the documentation other than the markup.
<div class="list">
<label class="item item-input item-select">
<div class="input-label">
Lightsaber
</div>
<select>
<option>Blue</option>
<option selected>Green</option>
<option>Red</option>
</select>
</label>
</div>
Is there a CodePen or something that describes how to get which item the user selected?
Thank you!
Auro
September 10, 2014, 12:15pm
2
you could use ng-modal
it will then do a 2-way databinding.
devine a variable in controller ($scope.selectValue)
and in html use :
<select ng-modal="selectValue">
<option>Blue</option>
<option selected>Green</option>
<option>Red</option>
</select>
dont forget to bind controller.
if you want to try something different:
OK, I see, that’s cool. So I now have this…
How do I set the initial value.
How do I get the new value that is selected?
Thanks!
Auro
September 10, 2014, 1:00pm
4
as you do it right now he wants an item form $scope.numbers.
but i think you just want to pass a key and then select.
For this you have to assign the key with ng-option like this
ng-options="number.key as number.value for number in numbers"
here an examle:
note : using key = ‘3’ you have to set $scope.myNumber = ‘3’; (with upper quote)
OK, that’s working great too now. Thank you.
But how do I get the new value that they changed to in the controller? I need to act on that new value?
Thanks!
Auro
September 10, 2014, 1:59pm
6
when you change the value in the select it will be saved in myNumber.
do you need to do something when value is changed?
Yes, I need to save that value to localstorage but don’t know how to tap into the event of the select.
duall
September 11, 2014, 6:30pm
8
I also need to fire some action onchange of the select, one way could be to use ng-model for binding something like ‘currentselected’ in scope, then do $scope.$watch(‘currentselected’ …
How is the common angular way? is this not recommended?
I added this:
ng-change=“valueChanged()”
1 Like
duall
September 11, 2014, 6:35pm
10
i have to write 20 letter minimun:
thats it, thanks!