I have a dropdown in my HTML page as follows:
<select id="monthBox" ng-model="month">
<option value="{{month}}" ng-repeat="month in months">{{month}}</option>
</select>
The dropdown's datasource is months, and it's bound to the model month. Initially it has numbers from 07 to 12, and default selected is 07:
However, this datasource changes. For example, after the user clicks 'next year' button, the list becomes [01,02..., 12].
What I'm trying to achieve is, the selected value should remain as 07. But when the list changes, the selected value is automatically emptied. It becomes either 01, or an empty option, depending on the browser and device I test.
I have tried following solutions, but none worked:
1. On the click of 'next year' button, I update the model. In the controller, I make it 07 again:
$scope.model = '07';
But, even though the model is updated, the dropdown still shows 01.
2. I have tried programmatically setting the DOM's value as follows:
var element = document.getElementById('monthBox');
element.value = $scope.month;
However, this does not take any effect either. The dropdown still shows 01.
Any suggestions? Thanks.


ng-model. Create a plunker demo that replicates problem$scope.month = '07';, not$scope.model = '07';. I would suggest discarding<option ng-repeat...>and instead utilizingng-optionson the<select>element. In any case, there must be something else going on that you're not showing because what you have shown should be working (without having to use either of your numbered solutions).