angularjs - Validate that all of the checkboxes are checked in ionic -


i have form list of checkboxes, shown here:

$scope.devicelist = [    { text: "dev 0", checked: false },    { text: "dev 1", checked: false },    { text: "dev 2", checked: false },    { text: "dev 3", checked: false },    { text: "dev 4", checked: false }  ];
<form>      <ion-checkbox class="checkbox-balanced"                    ng-repeat="item in devicelist"                    ng-model="item.checked"                    ng-required="true">        {{ item.text }}      </ion-checkbox>  </form>

of course have more elements. case show relavent code.

now, have validation form cannot sent until checkboxes checked. suggestions of elegant solution that?

thanks in advance

maybe function following trick:

$scope.validate = function(){    var numchecked = $filter($scope.devicelist, function(device) {      return device.checked    }).length;    return $scope.devicelist.length == numchecked;  }

and don't forget inject $filter service in controller or won't work


Comments

Popular posts from this blog

c - CUDA code not processing if block properly -

Android Capture Image From Camera -

oracle11g - get root domain from url Oracle sql regex_substr -