2013-09-21 70 views
1

我要動態地更改按鈕更改下拉選項單擊角JS

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> 

的點擊下拉選項使用這個js

var myApp = angular.module('myApp',[]); 

myApp.controller('exerciseTypeCtrl',function($scope,indoors,outdoors) 
{ 
    $scope.types = indoors; 
    $scope.update = function() { 
    } 
}); 

默認情況下,我數據綁定indoors,我想結合的NG-單擊事件outdoors數據,以便動態下拉更新 我需要幫助的日是問題

+0

除非有你不包括在你的問題的東西,這似乎很簡單。你有什麼嘗試? –

+0

我想要說,可以改變下拉數據。一些鈕click事件 我有什麼按鈕的那個點擊事件,以取代數據到新的做我有拖DATAS一個在'indoors'已經結合等是'outdoors',我想,以取代點擊事件 我是新的角JS – Blu

+0

@SimonBelanger請這個問題 http://stackoverflow.com/questions/18932585/angular-js-drop-down-values-change-dynamically – Blu

回答

0

爲此,您應該button下在其中定義select組件,然後在ng-click事件button相同ng-controller範圍調用function您將在同一個控制器創建像你update function並且在功能你會在分配像$scope.types = outdoors新的價值觀它

我創建簡單的example這個你應該看看這個 感謝

1
$scope.update = function() { 
}; 

替換爲:

$scope.update = function() { 
    $scope.types = outdoors; 
} 

DEMO