2016-10-04 78 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