[英]Change Dropdown option on Button Click in Angular JS
i want to change the dropdown options dynamically on click of button 我想在单击按钮时动态更改下拉选项
HTML Code HTML代码
<ul data-role="listview" data-inset="true">
<li ng-controller="exerciseTypeCtrl">
<select id="exerciseType" data-role="listview" ng-options="type as type.text for type in types.cast " ng-model="item" ng-change="update()">
</select>
</li>
</ul>
Using This JS 使用这个JS
var myApp = angular.module('myApp',[]);
myApp.controller('exerciseTypeCtrl',function($scope,indoors,outdoors)
{
$scope.types = indoors;
$scope.update = function() {
}
});
By Default I bind data indoors
and I want to bind outdoors
data on ng-click event so drop down updates dynamically I need Help on this issue 默认情况下,我在
indoors
绑定数据,并且我想在ng-click事件上绑定outdoors
数据,因此动态下拉更新我需要有关此问题的帮助
For this you should make button
under the same ng-controller
scope in which you defined select
component and then on ng-click
event of that button
you call function
which you will create in same controller like your update function
and in that function you will assign new values like $scope.types = outdoors
in it 为此,您应在定义
select
组件的ng-controller
范围内创建button
,然后在该button
ng-click
事件中调用function
,该function
将在同一控制器中创建,如update function
并在该函数中分配新值,例如$scope.types = outdoors
I create simple example for this you should check this out Thanks 我为此创建了一个简单的示例 ,您应该检查一下
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.