使用ng-repeat
,我的行ng-model
值为patentAppData.defaultSelect
。我需要重置此行中的select
元素,并通过这样做实现了这一目标:
$scope.transactionListFilter = function(data, filter, i) {
if(filter == 'clientRefFilter') {
$scope.filter = data;
$scope.patentAppData.defaultSelect = null;
} else {
$scope.filter = data;
$scope.clientRefData.defaultSelect = null;
}
}
<tr ng-repeat="row in $data">
<select ng-options="item.patentUI.patentApplicationNumber for item in row.renewalUIs" ng-change="transactionListFilter(patentAppData.defaultSelect, 'patentAppFilter', row.id)" ng-model="patentAppData.defaultSelect" >
</tr>
<select ng-options="item.patentUI.clientRef for item in row.renewalUIs" ng-change="transactionListFilter(clientRefData.defaultSelect, 'clientRefFilter', row.id)" ng-model="clientRefData.defaultSelect" >
<option value="">Multiple</option>
</select>
当用户选择其中一个下拉菜单时,其想法是另一个下拉菜单重置为默认值multiple
。它执行此操作,但在其他行select
选项未显示任何内容时发生错误。没有默认值multiple
,如果重置为null,则应该执行此操作,并且模型中没有值。
它应该如此工作:
`row1` `multiple` `ID0001` //the user has selected the second column, which resets the first columns select value to multiple
---------------------------
`row2` `multiple` `multiple`
发生了什么:
`row1` `multiple` `ID0001`
---------------------------
`row2` `multiple` ` ` //the controller is resetting all other rows connected to the model to blank
问题
如何更正我的脚本,以便仅调整该行的模型?