具有多个 select/Checkbox 的 ng 选项
ng-options with multiple select/Checkbox
是否可以从 ng-options select 多个选项或将 ng-options 值作为复选框?如果可能的话,有人可以给我举个例子吗?
要创建多个 select,只需将 多个 添加到您的 select 标签
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script type="text/javascript">
var app=angular.module("myApp", []);
app.controller(
"myCtrl",
function($scope){
$scope.values=[
{value:"0", text:"zero"},
{value:"1", text:"one"},
{value:"2", text:"two"}
];
}
);
</script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<div>Choose:</div>
<select name="choose" ng-model="choose" multiple>
<option ng-repeat="x in values" value="{{x.value}}">{{x.text}}</option>
</select>
</div>
</body>
</html>
是否可以从 ng-options select 多个选项或将 ng-options 值作为复选框?如果可能的话,有人可以给我举个例子吗?
要创建多个 select,只需将 多个 添加到您的 select 标签
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script type="text/javascript">
var app=angular.module("myApp", []);
app.controller(
"myCtrl",
function($scope){
$scope.values=[
{value:"0", text:"zero"},
{value:"1", text:"one"},
{value:"2", text:"two"}
];
}
);
</script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<div>Choose:</div>
<select name="choose" ng-model="choose" multiple>
<option ng-repeat="x in values" value="{{x.value}}">{{x.text}}</option>
</select>
</div>
</body>
</html>