2016-10-04 134 views
0

Im试图级联我的下拉框与另一个下拉菜单。因此,第二个下拉列表将列出与第一个下拉框中选择的项目相关的选项。我尝试过一个示例代码,下拉菜单仍然是空的。使用angularjs级联下拉菜单

HTML:

<ion-view view-title="Car Type"> 
    <ion-content ng-app="CarWash" ng-contorller="carBrand"> 
    <h3> Add/Edit the Car Types </h3> 
    Make: 
     <select id="brand" ng-model="carBrand" ng-options="brand for (brand,item) in brandList"> 
      <option value=''>Select</option> 
     </select> 

Type: 
<select id="makeType" ng-model="brandType" ng-options="item for (brand,item) in brandlist"> 
    <option value=''>Select</option> 
</select> 
    </ion-content> 
</ion-view> 

控制器:

[angular.module('CarWash',\[\]).controller('carBrand',\['$scope',function($scope){ 

    $scope.brandList={'Benz':\['Regular','Truck'\]}; 
}\])] 

链接1

回答

0

你可以做到这一点,

<select name="client" ng-model="selectedRequest.parentType" ng-options="c.name.en for c in clients.brandList" required></select> 
<select id="department" ng-model="selectedRequest.subType" ng-options="d.name.en for d in selectedRequest.parentType.children"> 

WORKING DEMO

+0

和其他查询将我能够使用此添加和删除功能。 – sree

+0

是的,你可以做到 – Sajeetharan

+0

你能分享样本代码@Sajeetharan – sree