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;
}