Using checkboxes and required with AngularJS

后端 未结 5 1689
独厮守ぢ
独厮守ぢ 2021-01-31 08:20

I\'ve tried to use the html5 required attribute for my group of checkboxes but I don\'t find a nice way to implement it with ng-form.

When a checkbox is che

5条回答
  •  半阙折子戏
    2021-01-31 08:49

    $scope.toggleAnimal = function(animal){ var index = $scope.selectedAnimals.indexOf(animal); if(index == -1) { $scope.selectedAnimals.push(animal); } else{ $scope.selectedAnimals.splice(index, 1); } }

    See the full detail and demo and other related examples

提交回复
热议问题