javascript - Check Boxes multi-select with model and will not compile without Ng-model -
i have ng-repeat outputs check boxes inside ng-repeat creates 7 tabs, same set of check boxes in them. have 2 problems. firstly i'm finding when check 1 box selects same 1 in other tabs , once checked won't un-check again.
i tried removing model, code not compile , tried using checklist-model
, checklist-value
in place of ng-model
, did not compile either.
the html check boxes is:
<div class="time-check" ng-repeat="service in settings.services"> <input type="checkbox" value="" ng-change="settings.showchecked($index)" ng-model="settings.rules[$index].checked" class="time-check-input" id="{{level.leveltmscode}}-{{day.day}}-{{service.timevalidation}}" name="check-{{day.day}}-{{level.leveltmscode}}"/> <label for="{{level.leveltmscode}}-{{day.day}}-{{service.timevalidation}}" class="time-check-input"></label> <span>{{service.timevalidation}}</span> </div>
and js generates whole accordion, tabs , boxes is:
settings.getdeliveryservices = function() { $http.get(resourcebase + "api/service/levels").success(function(data) { settings.servicelevels = data; // service days $http.get(resourcebase + "api/service/days").success(function(days) { settings.servicedays = days; // build accordion settimeout(() => settings.triggerclick(settings.servicelevels), 500); $http.get(resourcebase + "api/service/services").success(function (services) { settings.services = services; // build collection of possible rules (var = 0; < settings.servicelevels.length; a++) { settings.rulestmscode.push(settings.servicelevels[a].leveltmscode + "-"); } (var b = 0; b < settings.servicedays.length; b++) { settings.rulesday.push(settings.servicedays[b].day + "-"); } (var c = 0; c < settings.services.length; c++) { settings.rulestime.push(settings.services[c].timevalidation); } var allarrays = [settings.rulestmscode, settings.rulesday, settings.rulestime]; function allpossiblecases(arr) { if (arr.length === 1) { return arr[0]; } else { var result = []; var allcasesofrest = allpossiblecases(arr.slice(1)); (var = 0; < allcasesofrest.length; i++) { (var j = 0; j < arr[0].length; j++) { result.push(arr[0][j] + allcasesofrest[i]); } } return result; } } var uncheckedrules = allpossiblecases(allarrays); (var = 0; < uncheckedrules.length; i++) { settings.rules.push({ id: uncheckedrules[i], checked: false }); } }); }); }); }
my endpoint have these check boxes load in , each tab's set separate each other , when check them want list of whats been checked.
ok, turns out if create dummy object ng-model checks 1 checkbox.
<div class="time-check" ng-repeat="service in settings.services"> <input type="checkbox" value="" ng-change="settings.showchecked($index)" ng-model="newobject[item.name]" class="time-check-input" id="{{level.leveltmscode}}-{{day.day}}-{{service.timevalidation}}" name="check-{{day.day}}-{{level.leveltmscode}}"/> <label for="{{level.leveltmscode}}-{{day.day}}-{{service.timevalidation}}" class="time-check-input"></label> <span>{{service.timevalidation}}</span> </div>
Comments
Post a Comment