如何在角度为ng-repeat的情况下选择下拉列表

时间:2016-09-19 10:23:41

标签: angularjs asp.net-mvc-4 angularjs-ng-repeat

通过使用此代码,我可以获得下拉列表ID(如果我评论ng-repeat

<tr @*ng-repeat="r in rvm"*@ @*>
    <td>
        <select ng-model="ID" ng-options="c.ID as c.Name for c in customer" ng-change="GetAccountBalance($index)" style="width:150px;height:22px;" name=" tCustomer">
            <option value="">Select Customer</option>
        </select>
    </td>
</tr>

的javascript

 $scope.GetAccountBalance = function (index) {
    var getAccountBalance = ReceiptsService.GetAccountBalance($scope.ID);
    var id = $scope.ID;
    alert(id);
 }

但我的要求是在下拉列表更改中添加新行

<tr ng-repeat="r in rvm">
    <td>
        <select ng-model="ID" ng-options="c.ID as c.Name for c in customer" ng-change="GetAccountBalance($index)" style="width:150px;height:22px;" name=" tCustomer">
            <option value="">Select Customer</option>
        </select>
    </td>
</tr>

的javascript

$scope.rvm = [{}];

$scope.GetAccountBalance = function (index) {
    if ($scope.rvm.length == (index + 1)) {
        $scope.rvm.push({});
    }
}
var getAccountBalance = ReceiptsService.GetAccountBalance($scope.ID);
var id = $scope.ID;
alert(id);

我是否可以使用此代码添加新行,但我没有选择id, 如何选择下拉列表ID? 如果我删除ng-repeat我正在识别,

0 个答案:

没有答案