我有一个ng-repeat嵌套在另一个ng-repeat中.我想在单击按钮时将某些值推送到第二个数组
<div ng-repeat="vehicle in vehicleList"> <div>{{vehicle.number}}</div> <input name="addName" value="add" ng-click="addVehicle(vehicle)" <div ng-repeat="categoryList in vehicle.category"> <div>{{categoryList.name}}</div> </div> </div>
I tried following code but it's not working $scope.vehicleList=[]; $scope.addVehicle = function(){ $scope.vehicleList.push({ category:'car' }); }
谁可以帮我这个事.谢谢
<div ng-repeat="vehicle in vehicleList"> <div>{{vehicle.number}}</div> <input name="addName" value="add" ng-click="addVehicle($index,vehicle)"> <div ng-repeat="categoryList in vehicle.category"> <div>{{categoryList.name}}</div> </div> </div> $scope.vehicleList = []; $scope.addVehicle = function(index,vehicle) { $scope.vehicleList[index].category.push({ name: vehicle }); };