I have a <select>
element in my html page. The <option>
s are given through a loop. The selected value is stored using a ng-model
. This data is now push to a database. The next time that page reloads I would like the the <select>
field to hold the previously selected option. Is there anyway to do it?
I have seen that ng-model
generally fills text fields on it own. I tried to do the same with <select>
-<option>
but it doesn't work
<select ng-model="option">
<option value = "" disabled selected>---Choose an Option--</option>
<option ng-repeat = "x in option" value="x">{{x}}</option>
</select>