0
我试图删除级联下拉列表复选框,即下拉列表中的项目及其相关的复选框项目必须在按钮被删除时点击。我无法从下拉列表中删除选定的项目,所以请帮我删除所需的项目。删除级联下拉列表中的项目
HTML:
<ion-view view-title="Car Type">
<ion-content ng-contorller="carBrand">
<h3> Add/Edit the Car Types </h3>
{{sample}}
Make:
<!--select name="client" ng-model="selectedRequest.continent" ng-options="c.name for c in brandList" required></select-->
<select ng-model="carBrand" ng-options="make.name for make in brandList"></select>
Type:
<ion-checkbox ng-model="cartype" ng-repeat="brandType in carBrand.types" ng-disabled="!carBrand">
<span>{{brandType}}</span>
</ion-checkbox><br><br>
<button ng-click="addEntry()">Edit</button>
<button ng-click="home()">Back</button>
<button ng-click="delete($index)">Delete</button>
</ion-content>
</ion-view>
控制器:
var carService =angular.module('carService', ['ionic']);
carService.controller('carBrand',['$scope',function($scope){
$scope.brandList=[
{'name':'Benz', 'types':['SUV', 'Sedan']},
{'name':'BMW', 'types':['SUV', 'Sedan', 'Van']}
];
$scope.remove=function(index){
delete $scope.brandList[$index];
};
}]);
这将有助于删除{name:Benz,types:['suv','seadan']},并且可以将它放在plnkr中,以便理解它。 – sree
删除下拉列表中的项目并没有发生列表@taguenizy – sree
[plnkr](https://plnkr.co/edit/SdRRcw57vmYJMsJLo7l1?p=preview)@sree – taguenizy