1

我使用复选框类型的输入来缩小我的搜索结果;问题是我将复选框放入模式中,当我选中其中许多并关闭模式时,选中的输入变为未选中。

我希望每次打开检查的模态输入时都被检查。

 var filterTemps = [
        "partial/uicomponent/mdlFilters/mdl.estateType.filter.html",
    ];

    $scope.showReleventMdl = function(num){

        var filtersModal = $modal({
            backdrop:true,
            placement:'top',
            templateUrl :  filterTemps[num],
            controller : 'filterCtrl',
            show: false
        });

        filtersModal.$promise.then(filtersModal.show);
    };
<!-- trigger the function for call modal -->
 <ul class="nav navbar-nav">
   <li>
     <a href="" ng-click="showReleventMdl(0)" ng-bind="string.pages.form.estateType"></a>
     </li>
   ...
</ul>
--------------------------------------------------
<!-- my Modal Template -->
<div class="modal-body">

                <ul class="filterList">
                    <li class="filterListItem half" ng-repeat="item in string.pages.mainPage.estateTypes">
                        <input id="estateType{{$index}}" ng-click="checked(item)" type="checkbox" class="filterCheck">
                        <label for="estateType{{$index}}" ng-bind="item"></label>
                    </li>
                </ul>

            </div>

我想知道有什么方法可以存储检查的输入并使用模态将它们带回检查状态?TNKS 很多

4

1 回答 1

0

您没有为 $scope 对象设置任何值。尝试这个...

<div class="modal-body">    
  <ul class="filterList">
    <li class="filterListItem half" ng-repeat="item in string.pages.mainPage.estateTypes">
      <input id="estateType{{$index}}" type="checkbox" ng-model="checkbox[$index].checked" class="filterCheck">
      <label for="estateType{{$index}}" ng-bind="item"></label>
    </li>
  </ul>

</div>

然后,在您的控制器中,您可以为您的复选框值设置 $scope 对象。

$scope.checkbox = {};
于 2015-10-18T20:00:48.907 回答