如何在选择重复下拉列表

时间:2018-03-08 16:17:02

标签: javascript angularjs

HTML

<select class="form-control" type="text" name="productname" ng-model="prod" ng-change="GetSubCategory(prod)/>
<option value="">select</option>
<option ng-repeat="pro in ProductsArray" value="{{pro}}">{{pro.ProductName}}</option>
</select>

<select class="form-control" type="text" name="subprod" ng-model="subprod" />
    <option value="">select</option>
    <option ng-repeat="subpro in SubProductsArray" value="{{subpro}}">{{subpro.SProductName}}</option>
</select>

<button type="sumbit" ng-click="add_po_Product()" class="btn btn-primary" ng-model="add"></button>

的JavaScript

$scope.products = [];
$scope.prod = [];
$scope.subprod = [];

$scope.add_po_Product = function() {       
    $scope.prod = JSON.parse($scope.prod);
    $scope.subprod = JSON.parse($scope.subprod);
    $scope.products.push({  
        Pid: $scope.prod.ProductId,
        PName: $scope.prod.ProductName,
        SPid: $scope.subprod.SProductId,
        SPName: $scope.subprod.SProductName,
    });
    $scope.prod= '';
    $scope.subprod= '';
}

我在这里使用SubProductsArray加载ng-change="GetSubCategory()"。但我无法将值推送到数组中。 我做错了吗?

0 个答案:

没有答案