简体   繁体   English

Cacading Drop Down 2nd Dropdown名称没有得到更改angularjs?

[英]Cacading Drop Down 2nd Dropdown name Not getting Change in angularjs?

I have mobile brand list .here based on 1st drop down 2nd dropdown list is coming but .when i select nokia in 1st dropdown ,Lumia 735,Asha 230,Lumia 510 these are coming in 2nd dropdown,in 2nd dropdown i have selected Lumia 735 its working fine but again i have selected Samsung in 1st dropdown here 2nd drop list got changed but already selected Lumia 735 still showing . 我有移动品牌列表。根据第一下拉列表,这里有第二下拉列表,但是。当我在第一下拉列表中选择nokia时,Lumia 735,Asha 230,Lumia 510这些都进入了第二下拉列表,在第二下拉列表中我选择了Lumia 735它的工作很好,但是我还是在第一个下拉菜单中选择了三星,第二个下拉列表变了,但是已经选择了Lumia 735。 expectation:based on 1st dropdown selection 2nd dropdown should come 2.after 1st and 2nd dropdown selection ,when i submit i need to get id,brandname,modelname 期望:基于第一个下拉菜单选择第二个下拉菜单应该在第二个下拉菜单之后。在我提交第二个下拉菜单之后,我需要获取ID,品牌名称,型号

 angular.module('myApp', ['ui.filters']) .controller("myCntrl", function ($scope) { $scope.items= [{ id: "986745", brandname: "Nokia", modelname: "Lumia 735", price: "7500" }, { id: "896785", brandname: "Nokia", modelname: "Asha 230", price: "12000" }, { id: "546785", brandname: "Nokia", modelname: "Lumia 510", price: "9500" }, { id: "144745", brandname: "Samsung", modelname: "Samsung 110", price: "13000" }, { id: "986980", brandname: "Samsung", modelname: "Galaxy A5", price: "5500" }, { id: "586980", brandname: "Samsung", modelname: "Galaxy Note 4 Duos", price: "5500" }, { id: "986980", brandname: "Samsung", modelname: "Galaxy A5", price: "5500" }, { id: "586980", brandname: "Samsung", modelname: "Galaxy Note 4 Duos", price: "1000" }, { id: "232980", brandname: "Htc", modelname: "One X9", price: "1000" }, { id: "456798", brandname: "Htc", modelname: "Desire 820", price: "1000" } ] $scope.test = function() { console.log($scope.id); console.log($scope.selectedBrand); console.log($scope.selectedModel); } }) $(function () { setTimeout(function () { $("select").select2(); }, 100); }); //]]> 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.1/js/select2.full.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.1/css/select2.min.css" /> <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui/0.4.0/angular-ui.min.js"></script> <div ng-app="myApp"> <div ng-controller="myCntrl"> <form name="addvehicleForm" data-ng-submit="test()" novalidate> <label>List Of Brand</label> <label for="singleSelect"> select: </label> <select ng-model="selectedBrand"> <option ng-repeat="item in items | unique: 'brandname'" value="{{item.brandname}}">{{item.brandname}}</option> </select> <select ng-model="selectedModel"> <option ng-repeat="item in items | filter: {brandname: selectedBrand}" value="{{item.modelname}}">{{item.modelname}}</option> </select> <div class="padding"> <button class="button button-full button-stable" type="submit" > Save </button> </div> </form> </div> </div> 

pls run above code and solve the issue 请运行上面的代码并解决问题

Seems all you want is to clear the model if you change the brand, to do that, just put ng-click on 似乎您想要的只是如果更改品牌就清除模型,要执行此操作,只需将ng-click

<select ng-model="selectedBrand">
<option ng-repeat="item in items | unique: 'brandname'" value="{{item.brandname}}" 
               ng-click="setNull()">{{item.brandname}}</option>
</select>

and in script do something like 在脚本中执行类似

angular.module('myApp', ['ui.filters'])
    .controller("myCntrl", function ($scope) {

          $scope.setNull = function(){

               $scope.selectedModel = "";

          }
          .
          .
          .

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 显示基于First Drop Down PHP JS的第二个下拉列表 - Show 2nd Dropdown based on First Drop Down PHP JS 显示基于第一个下拉列表的第二个下拉列表不起作用 - Showing 2nd Dropdown based on First drop down not working 如何在第二个下拉列表中更改设置的默认值 - How to change the setected default value in a 2nd drop down list 在第一个下拉菜单被选中后显示第二个下拉菜单的内容。 - Show content of 2nd Drop down after 1st Drop down getting selected. 如何在第一个选择上禁用(或更改颜色)第二个下拉选项? - How to disable (or change color) of 2nd drop down option depenging on 1st selection? 如何根据从第一个下拉菜单自动更改的第二个下拉菜单更改第二个文本框的值? - How to change the 2nd textbox value based on the 2nd dropdown that is automatically changed from 1st dropdown? 与第二下拉选择相关的第二下拉选择 - 2nd Drop Down selection to be related to the selection on the 1st Drop Down Selection 通过在codeigniter php中使用ajax,根据第一个下拉结果填充第二个下拉列表 - populate 2nd drop down based on 1st drop down result by using ajax in codeigniter php 从下拉菜单中逐页阅读-找不到第二页上的下拉菜单 - Read a page after another from a drop down menu - Can't find the drop down on 2nd page 如何根据第一个下拉值使第二个下拉列表自动选择值 - How to make 2nd drop down list auto select value based on 1st drop down value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM