Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html angularjs在多个下拉列表上设置不同的选项_Html_Angularjs_Dropdownbox - Fatal编程技术网

Html angularjs在多个下拉列表上设置不同的选项

Html angularjs在多个下拉列表上设置不同的选项,html,angularjs,dropdownbox,Html,Angularjs,Dropdownbox,我希望有办法做到这一点。 我使用ng repeat创建下拉列表;创建的下拉列表的数量取决于我从数据库检索的数据。 根据数据,我想为每个下拉列表设置一个初始选项值。 考虑下面的代码: <span class="finds" ng-model="cond" ng-repeat="condin list"> <select ng-model="selected_item" ng-options="condition.name for condition in conditionTy

我希望有办法做到这一点。 我使用ng repeat创建下拉列表;创建的下拉列表的数量取决于我从数据库检索的数据。 根据数据,我想为每个下拉列表设置一个初始选项值。 考虑下面的代码:

 <span class="finds" ng-model="cond" ng-repeat="condin list">
<select ng-model="selected_item" ng-options="condition.name for condition in conditionTypes"></select>

<input ng-model="cond.name"/>
</span>

我可以通过更改选定的_项值来更改下拉列表的值,但这会更改所有下拉列表的值(因为变量已绑定)。 那么,我是否可以独立更改每个下拉列表的值,而不影响其他下拉列表(也不创建多个变量)


谢谢

如果您想根据第一个选择框中的值用适当的数据填充右侧下拉列表,您应该这样做

假设您有两个下拉列表,如:

<select ng-model="first" class="form-control" ng-change="secondcall()">
      <option ng-repeat = "firstdata in firstdatas" value="{{firstdata}}">{{firstdata}}</option>
 </select>
<select ng-model="second" class="form-control">
      <option ng-repeat = "seconddata in seconddatas" value="{{seconddata}}">{{seconddata}}</option>
</select>

只有一个ng repeat用于创建一组下拉列表。 我需要从数据库中检索数据,然后根据数据定义需要多少下拉列表。 ng重复这样做。如果在处理完数据后,我需要两个下拉列表,那么我将在循环中创建两对 dropdown1 dropdwon1.0{1.0应根据在1中选择的选项加载列表


dropdown2.0{2.0应根据在2中选择的选项加载列表否,每个选择应绑定到单独的模型谢谢,我需要独立设置每个下拉列表的值。您的建议似乎合适,但您能否告诉我如何使用它。如何使用控制器和$index为每个下拉列表设置合适的值?是的,您没有需要为每个下拉菜单设置单独的ng模型我认为动态设置是不可能的。你需要知道有多少个下拉菜单,然后根据它进行操作。是的,这有点难,我的意思是,即使我知道有多少个下拉菜单,我如何动态设置ng模型?是否可以在不使用usi的情况下设置下拉菜单的选项值ng ng模型?我尝试了selected_item_u$index,但它不起作用。假设我已经和ng repeat创建了一对3个下拉列表drpdwn1 drpdwn1.0 drpdwn3 drpdwn2.0 drpdwn3 drpdwn3.0例如,如果在drpdwn1中我选择了年龄,我希望drpdwn1.0显示年龄列表如果在drpdwn2中我选择了婚姻状况,我希望状态列表加载到drpdw上n2.0等等
$scope.secondcall = function () {
  var value = $scope.first;
  //Make an API call to fetch details with the select value and in the success do this

    $scope.seconddatas = data from the api;

};