Can someone help me with setting the same value in multiple drop-down lists using angular.js? Below is an explanation of my code.
<table class="table table-bordered table-striped table-hover" id="dataTable">
<tr>
<td width="100" align="center">Time <i class="fa fa-long-arrow-right"></i>
<BR>Day <i class="fa fa-long-arrow-down"></i>
</td>
<td width="100" align="center" ng-repeat="hour in hours" ng-bind="hour"></td>
</tr>
<tbody id="detailsstockid">
<tr ng-repeat="days in noOfDays">
<td width="100" align="center" style=" vertical-align:middle" ng-bind="days"></td>
<td width="100" align="center" style="padding:0px;" ng-repeat="hour in hours">
<table style="margin:0px; padding:0px; width:100%">
<tr>
<td>
<select id="coy" name="coy" class="form-control" ng-model="sub_name " ng-options="sub.name for sub in listOfSubjectName track by sub.value">
</select>
</td>
</tr>
<tr>
<td>
<select id="coy" name="coy" class="form-control" ng-model="fac_name " ng-options="fac.name for fac in listOfFacultyName track by fac.value">
</select>
</td>
</tr>
</td>
</table>
</td>
</tr>
</tbody>
</table>
The values are being set dynamically in each row of this table, and the values are the same for all rows and columns. The code for my controller file is provided below.
$scope.noOfDays = [];
$scope.days = {
'0': "Monday",
'1': 'Tuesday',
'2': 'Wednesday',
'3': 'Thursday',
'4': 'Friday'
}
$scope.hours = [
'9AM :: 10AM',
'10AM :: 11AM',
'11:15AM :: 12:15PM',
'12:15PM :: 01:15PM',
'02PM :: 03PM',
'03PM :: 04PM',
'04PM :: 05PM'
]
for (var i = 0; i < 5; i++) {
$scope.noOfDays.push($scope.days[i]);
}
$scope.listOfSubjectName=[{
name: 'Select Course',
value: ''
}]
$scope.listOfFacultyName=[{
name: 'Select Faculty',
value: ''
}]
If I select a value from the Select Course
dropdown list under '12:15PM :: 01:15PM'
, that selected value should automatically be set in the next 3 sets of times (
i.e. '02PM :: 03PM','03PM :: 04PM','04PM :: 05PM'
) and displayed in the Select Course dropdown lists corresponding to those times. I can select the value from anywhere, but once selected, it should be set in the next 3 dropdown lists. Can someone assist me with this functionality?