0
我該如何同步單選按鈕的下拉菜單,所以當我檢查一個按鈕,下拉菜單動態改變相同的選項?如何用單選按鈕綁定無線電下拉菜單?
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.colors = [
{model : "Red"},
{model : "Green"},
{model : "Blue"},
{model : "Purple"}
];
});
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<p>What is your favorite color?</p>
<select ng-model="selectedColor" ng-options="x.model for x in colors">
</select>
<input type="radio" ng-model="colors.model" value = "{{selectedColor.model}}"> Red
<input type="radio" ng-model="colors.model" value = "{{selectedColor.model}}"> Green
<input type="radio" ng-model="colors.model" value = "{{selectedColor.model}}"> Blue
<input type="radio" ng-model="colors.model" value = "{{selectedColor.model}}"> Purple
</div>
</body>
</html>
,也反之亦然 – blooddrunk
所以你想改變下拉菜單的值取決於單選按鈕更新其他值? –
您是否檢查過:https://docs.angularjs.org/api/ng/directive/ngValue? – Wandrille