Javascript Angularjs-禁用ng选项中的选项(如果已在相邻选择中选择)
我有一个表,其中有两个选择选项是动态的Javascript Angularjs-禁用ng选项中的选项(如果已在相邻选择中选择),javascript,angularjs,time,Javascript,Angularjs,Time,我有一个表,其中有两个选择选项是动态的 <tr> <th>Start time</th> <th>End time</th> </tr> <tr ng-repeat="s in config.time"> <td> <select ng-model="s.start_time" class="form-control" ng-options="opti
<tr>
<th>Start time</th>
<th>End time</th>
</tr>
<tr ng-repeat="s in config.time">
<td>
<select ng-model="s.start_time" class="form-control" ng-options="option for option in config.hrs"></select>
</td>
<td>
<select ng-model="s.end_time" class="form-control" ng-options="option for option in config.hrs"></select>
</td>
</tr>
我想禁用在开始时间中选择的小时作为结束时间,如果我添加另一行,我不想启用以前选择的小时
我试着像这样使自己瘫痪
但它会在结束时禁用整个选项
图1是我当前的输出
图2是我的预期输出 我认为您当前的设置不可能做到这一点 备选案文1 保存一个对象数组,例如[time:'08:00',selected:false},…]。然后,您可以只显示selected===false的选项,虽然不使用ng选项,但使用简单的ng repeat on 备选案文2
在选择时,从数组中删除所选时间并将其存储在另一个变量中。您可以尝试使用以下类型的代码-
<td>
<select ng-model="s.end_time" class="form-control">
<option ng-repeat="option in config.hrs" ng-disabled="s.start_time > option" >{{option}}</option>
</select>
</td>
希望它能给你一个想法并帮助你解决这个问题。如果你能创建一个很棒的代码片段或小提琴,那么你可以使用ng change调用一些函数并设置逻辑
<td>
<select ng-model="s.end_time" class="form-control">
<option ng-repeat="option in config.hrs" ng-disabled="s.start_time > option" >{{option}}</option>
</select>
</td>