Reputation: 33
Is it possible to select multiple options from ng-options or have ng-options values as check boxes? If possible can someone give me an example please?
Upvotes: -1
Views: 2738
Reputation: 4453
To create a multiple select just add multiple to your select tag
<!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>
Upvotes: 0