使用ng-repeat选择单行ng-model

时间:2017-11-13 16:13:23

标签: javascript angularjs

使用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

问题

如何更正我的脚本,以便仅调整该行的模型?

0 个答案:

没有答案