-1

是否可以从 ng-options 中选择多个选项或将 ng-options 值作为复选框?如果可能的话,有人可以给我一个例子吗?

4

1 回答 1

0

要创建多选,只需将多个添加到您的选择标签

<!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>

于 2018-02-26T18:38:47.120 回答