I want to add two new select boxes (from and until) using ng-click and then add then update the users selection in my scope. I can add the select boxes but I'm having trouble binding the selects to my array.
My HTML:
<div ng-repeat="time in availability.times" class="calendar--availability--time">
<select ng-model="availability.times.time.from[$index]">
<option>...</option>
</select>
<select ng-model="availability.times.time.to[$index]">
<option>...</option>
</select>
</div>
<button class="button--secondary margin__top" ng-click="addNewTime()"><span>Add another slot</span></button>
My js/angular:
$scope.availability = {
times: [
time: {from: '09:00', to: '21:00'}
]
}
$scope.addNewTime = function() {
var newTime = {time: { from: '', until: ''}};
$scope.availability.times.push(newTime);
}