<!DOCTYPE html>
<html ng-app="fromApp">
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="angular.min.js"></script>
</head>
<body>
<p ng-controller="formController">
<p class="form-group">
<form name="formData">
<label class="checkbox-inline">
<input type="checkbox" name="favoriteColors" value="red" ng-model="formData.favoriteColors.red"> Red
</label>
<label class="checkbox-inline">
<input type="checkbox" name="favoriteColors" value="blue" ng-model="formData.favoriteColors.blue"> Blue
</label>
<label class="checkbox-inline">
<input type="checkbox" name="favoriteColors" value="green" ng-model="formData.favoriteColors.green"> Green
</label>
<button ng-click="check()">提交</button>
</form>
</p>
</p>
<script>
var app= angular.module('fromApp',[]);
app.controller('formController',function($scope){
$scope.fromData={};
$scope.check=function(){
}
});
</script>
</body>
</html>
如何实现点击提交当checkbox选中超过2个做出提示即可
form
etfrom
sont écrits de manière si confusePourquoi ne pas utiliser la radio
Si vous voulez vraiment faire ça, vous pouvez
$scope.check=function(){
var vérifié=[];
si(!$scope.formData.favoriteColors){
retourner faux ;
>
si($scope.formData.favoriteColors.red)
checké.push('red');
si($scope.formData.favoriteColors.blue)
checké.push('bleu');
si($scope.formData.favoriteColors.green)
checké.push('vert');
}`