【问题标题】:cascading the drop-down using angularjs使用 angularjs 级联下拉菜单
【发布时间】:2016-10-04 09:13:08
【问题描述】:

我试图将我的下拉框与另一个下拉框级联。所以第二个下拉框将列出与第一个下拉框中选择的项目相关的选项。我尝试了一个示例代码,然后下拉 - down 仍然是空的。

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

【问题讨论】:

    标签: angularjs ionic-framework


    【解决方案1】:

    你可以这样做,

    <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

    【讨论】:

    • 其他查询我可以使用它来添加和删除功能。
    • 我在 ionic 中尝试了这个逻辑,但它没有给出任何输出,下拉菜单仍然是空白的.. @Sajeetharan
    • @sree 检查你的 json
    • 因为我是 ionic 和 angularjs 的新手,你能解释一下为什么要检查 json 文件...对不起@Sajeetharan
    • 因为这是加载数据的地方,您能否创建一个示例并显示我会找出问题所在
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-03
    • 1970-01-01
    • 1970-01-01
    • 2022-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多