chekbox数组选择angularjs

时间:2016-08-16 11:12:52

标签: angularjs

嗨我正在考虑一年的范围并检查该范围之间的年份...这里是代码我也通过计算选择了多少来改变文本。 现在这个计数是正确的..但是当我点击复选框的下拉列表时没有选择任何元素...日志是正确的但是当我点击下拉列表时没有被选中。



length = EnteredText.to - EnteredText.from;
for (var i = 0; i <= length; i++) {
  if (checkifExists(vm.mkyears, EnteredText.from)) {
    vm.mkyears.push(EnteredText.from);
    $scope.singleScopeYear[vm.mkyears.indexOf(EnteredText.from)] = true;
    EnteredText.from++
  } else {
    $scope.singleScopeYear[vm.mkyears.indexOf(EnteredText.from)] = true;
    EnteredText.from++;
  }
}
// $scope.onYearChange();
var counter = 0;
for (var i = 0; i < Object.keys($scope.singleScopeYear).length; i++) {
  //it checked and it was true false
  if ($scope.singleScopeYear[i] == true) {
counter++;
  }
}
//this shows correct count 
$scope.mk_year.name = counter + " Selected";
//this also  shows correct   but when i click dropdown none are selected                    
console.log($scope.singleScopeYear);
&#13;
<-- Modal -->
<div class="form-group" ng-if="Year.year_value == 0">
  <div class="col-md-6 no-padding">
    <input type="number" name="yearFrom" class="form-control" placeholder="From" ng-model="model.fromText" required>
  </div>
  <div class="col-md-6 no-padding">
    <input type="number" name="yearTo" class="form-control" placeholder="To" ng-model="model.toText" required>
  </div>
</div><br>

<-- main -->
<div class="btn-group" uib-dropdown is-open="mkyear.isopen">
  <button id="mk-year" type="button" class="btn btn-default" uib-dropdown-toggle ng-disabled="isYearDisabled">
    {{ ' ' }} {{mk_year.name}} <span style="margin-left:5px;" class="caret"> </span>{{ ' ' }}
  </button>
  <ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="mk-year">

    <li ng-repeat="singleYear in showFilters.mkyears track by $index" style="padding-left:10px;" ng-click="$event.stopPropagation();">
      <input type="checkbox" ng-init="singleScopeYear[$index] = false" ng-value="$index" ng-model="singleScopeYear[$index]" ng-change="onYearChange($index)"> {{singleYear}}
    </li>
  </ul>
  <button class="btn btn-transparent" ng-disabled="isYearDisabled" ng-click="addmodal(4)">
    <span class="glyphicon glyphicon-plus"></span>
  </button>
</div>
    
&#13;
&#13;
&#13;

0 个答案:

没有答案