Reputation: 315
I have a form where a user needs to select the type of shifts for two weeks. What I need to do is to set UNIQUE default values for each cell, e.g. Day 1: D, Day2:N, etc.
. How can I achieve this?
fiddle: https://jsfiddle.net/fujik8467/axnm0cy9/24/
Upvotes: 0
Views: 1581
Reputation: 351
You can use this code:
<select ng-model="day.selectedShiftType" ng-options="shift as shift.strId for shift in shifts" ng-init="day.selectedShiftType = shifts[0]">
The above will always select first option but we can make this random using this code:
$scope.GetRandomIndex = function() {
return Math.floor((Math.random()*3)+1);
}
html code:
<select ng-model="day.selectedShiftType" ng-options="shift as shift.strId for shift in shifts" ng-init="day.selectedShiftType = shifts[GetRandomIndex()]">
Upvotes: 1