这很好用,除了我不能将var1初始化为""或者为null。我喜欢" All"要选择的项目,但它似乎没有注册为" All"通过ng值。点击该值后,它似乎有效。
angular.module('myApp', []);
angular.module('myApp').controller('test_controller1', function($scope) {
$scope.colors = [ "red", "green", "blue" ];
$scope.var1 = "";
});
...
<input type="radio" ng-model="var1" ng-value="" id="all"> <label for="all">All</label>
<input type="radio" ng-model="var1" ng-value="'red'" id="red_id"> <label for="red_id">red</label>
<input type="radio" ng-model="var1" ng-value="'green'" id="green_id"> <label for="green_id">green</label>
<input type="radio" ng-model="var1" ng-value="'blue'" id="blue_id"> <label for="blue_id">blue</label>
答案 0 :(得分:0)
刚刚意识到ng-value =“''”按我喜欢的方式工作。没关系。