子范围未按组重复更新复选框

时间:2016-12-23 07:24:32

标签: javascript angularjs angularjs-scope

我的AngularJs应用程序中有Ng重复的CheckBoxes列表

"(key, value) in MyScopeModel| groupBy: 'Filed'"

每个复选框列表都有一个复选框以选择此组全部或取消选择 问题是我何时更新$scope.MyScopeModel未更新值因此复选框不按预期工作 enter image description here

注意:此MY Customer Group By Filter

App.filter('groupBy', function () {
    return _.memoize(function (items, field) {
        return _.groupBy(items, field);
    }
    );
});

这是我的代码:

<div class="panel-group" ng-repeat="(key, value) in MyScopeModel| groupBy: 'Filed'">

            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
                        <a data-toggle="collapse" href="#{{ 'm-' + ($index + 1)  }}">{{($index + 1) + ' - ' + key }}</a>
                    </h4>

                    <input type="checkbox" ng-init="isMAllSelected=checkboxes[$index + 1]" ng-model="isMAllSelected"
                           ng-click="toggleMAll($index + 1)"/> SellectAll

                </div>
                <div ng-attr-id="{{ 'm-' + ($index + 1)  }}" class="panel-collapse collapse">
                    <div class="panel-body col-sm-12 table-responsive achievements">

                        <ul ng-repeat="k in value">

                            <li>

                                <label>
                                    <input type="checkbox" ng-model="k.Status"/>
                                </label>

                            </li>
                        </ul>
                    </div>

                </div>
            </div>
        </div>


$scope.MyScopeModel=date;// This Comming From Database and It Work as Expected The Problem Is When Update $scope.MyScopeModel value in ng-repeat not updated


    $scope.toggleMAll = function (index) {
        var toggleMStatus = $scope.checkboxes[index];
        angular.forEach($scope.MyScopeModel, function (itm) {
            if (itm.Mid === index) {
                itm.Status = toggleMStatus;

            }

        });


    }

0 个答案:

没有答案