I am trying to change the value from a selectbox on a buttonclick. I have a selectbox with all the months in it, and when I click a 'previous month' button, I want to change the selected value to the previous month but what I have now does not work correctly. It only changes one time
This is my HTML:
<select name="months" ng-model="monthFromSelector" ng-change="getSelectVal('monthFromSelector')">
<option ng-repeat="month in months" value="{{month}}">{{month}}</option>
</select>
<button ng-click="prevMonth()">Vorige maand</button>
And my controller:
$scope.months = ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"];
var now = new Date();
var thisMonth = $scope.months[now.getMonth()];
$scope.monthFromSelector = thisMonth;
$scope.prevMonth = function() {
thisMonth = $scope.months[now.getMonth() -1]
$scope.monthFromSelector = thisMonth;
console.log(thisMonth)
}