Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.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
Javascript 使用AngularJS更新下拉列表_Javascript_Angularjs_Drop Down Menu_Controller - Fatal编程技术网

Javascript 使用AngularJS更新下拉列表

Javascript 使用AngularJS更新下拉列表,javascript,angularjs,drop-down-menu,controller,Javascript,Angularjs,Drop Down Menu,Controller,我希望有机会从下拉列表中选择一个值,并单击链接以获取下拉列表的下一个值。如果单击链接,如何更新下拉列表中的选定值 <select class="dropdown-select" name="mySelect" id="chapter" ng-options="option.Icnumber for option in selected" ng-model="selected.Icnumber" ng-change="updateChapter(selected.Icnumber.Icnu

我希望有机会从下拉列表中选择一个值,并单击链接以获取下拉列表的下一个值。如果单击链接,如何更新下拉列表中的选定值

<select class="dropdown-select" name="mySelect" id="chapter" ng-options="option.Icnumber for option in selected" 
ng-model="selected.Icnumber" ng-change="updateChapter(selected.Icnumber.Icnumber)">
</select>

<a ng-show="nextChapter" class="ng-hide" ng-click="updateChapterNext(selected.Icnumber.Icnumber)">Next Chapter</a>

下一章

谢谢

Angular有一个称为双向绑定的功能,无论您在$scope中使用了什么,并且在模板中使用了它,当您更新控制器中的值时,它将自动更新模板中的值

对于您的问题,您可以使用
selected
作为下拉值

因此,在
updatecapternext
函数中修改所选
的值

所以


这将更新下拉列表中的选定值。Angular有一个称为双向绑定的功能,无论您在$scope中使用了什么,并在模板中使用它。当您更新控制器中的值时,它将自动更新模板中的值

对于您的问题,您可以使用
selected
作为下拉值

因此,在
updatecapternext
函数中修改所选
的值

所以

这将更新下拉列表中的选定值

$scope.updateChapterNext = function(param){
  // do your thing to call next chapter
  // and assign the response or new value to selected
  $scope.selected = newValueForSelected;
}