Angularjs 无法从模式中的筛选列表中获取筛选项

Angularjs 无法从模式中的筛选列表中获取筛选项,angularjs,filter,pagination,modal-dialog,ng-repeat,Angularjs,Filter,Pagination,Modal Dialog,Ng Repeat,我有一个页面,当选择某个指令时,我可以在其中打开一个模式窗口 加载该模式窗口时,我在其中有一个用于搜索的文本输入,一个有序列表列出除我选择的指令外的所有指令,一个下拉列表选择每页要查看的指令量,下一页和上一页的两个按钮,以及显示当前页和有多少页的文本 这看起来就像手动下拉列表现在什么都不做 到目前为止,我得到了我所有的指示正确,我的过滤器工作,每页的结果工作,下一个和上一个按钮改变页面。。。但我的numberOfPages函数似乎不起作用 这是模式HTML页面: <div>

我有一个页面,当选择某个指令时,我可以在其中打开一个模式窗口 加载该模式窗口时,我在其中有一个用于搜索的文本输入,一个有序列表列出除我选择的指令外的所有指令,一个下拉列表选择每页要查看的指令量,下一页和上一页的两个按钮,以及显示当前页和有多少页的文本

这看起来就像手动下拉列表现在什么都不做

到目前为止,我得到了我所有的指示正确,我的过滤器工作,每页的结果工作,下一个和上一个按钮改变页面。。。但我的numberOfPages函数似乎不起作用

这是模式HTML页面:

<div>
        Search: <input type="text" ng-model="search.Description"/> Manual: 
        <select ng-options="manual.Description for manual in manuals">

        </select>
    </div>
    <br />
    <div class="table clearfix" style="max-width: 800px; max-height: 300px; overflow: scroll;">
        <ol class="table-body clearfix">
            <li class="table-row clearfix" ng-repeat="item in ( filteredItems = ( instructions | filter:search:strict)) | startFrom:currentPage*showLimit | limitTo:showLimit" ng-include="'js/manuals/manuals-item-instruction-attachment-showInstruction.html'"></li>
        </ol>

    </div>
    <div>
        <button ng-disabled="currentPage == 0" ng-click="currentPage=currentPage-1">Previous</button>
            Page: {{currentPage + 1}}/{{numberOfPages()}}
        <button ng-disabled="currentPage >= numberOfPages() - 1" ng-click="currentPage=currentPage + 1">Next</button>
        Results per page:
        <select ng-model="showLimit">
            <option value="10">10</option>
            <option value="20">20</option>
            <option value="50">50</option>
            <option value="100">100</option>
        </select>
    </div>
这是我的模态控制器

var ModalInstanceCtrl = function ($scope, $modalInstance, instruction) {
    $scope.showLimit = 10;
    $scope.currentPage = 0;
    $scope.numberOfPages = function () {
        if ($scope.currentPage + 1 > Math.ceil($scope.filteredItems.length / $scope.showLimit)) {
            $scope.currentPage = 0;
        }
        return Math.ceil($scope.filteredItems.length / $scope.showLimit);
    }
    $http({ method: 'GET', url: '../api/Instructions/GetAllOtherInstructions', params: { 'instructionId': instruction.Id} }).success(function (result) {
        $scope.instructions = result;
    });
    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
    };
};
调试后,无论我试图将numberOfPages函数放在代码的何处,numberOfPages函数中的filteredItems始终未定义


为什么ng repeat中的filteredItems始终未定义?我在一个非模式页面中也有同样的东西,它工作得非常好。

在回复评论时,尝试创建一个对象来保存filteredItems属性。将继承并在父对象上创建属性:

$scope.data = { };
html:


应该设置filteredItems的代码在哪里?在ng中重复html?我不认为这是有效的。它是有效的,看。我还在一个页面中列出了所有用户,并使用分页对其进行过滤。它和我这里的东西完全一样,只是它不在模态中。我有一种感觉,我只是犯了一个愚蠢的错误,但我不能指出我做错了什么。你能用巴塔朗调试你的示波器吗?模态是否有它自己的范围,filteredItems无法达到?我不确定Batarang是如何工作的,我会阅读它。乍一看,我可以看到,在这个范围内,我拥有所有可以在currentPage、所选指令等中工作的内容,在下一个范围分支中,我拥有filteredItems和所有已过滤的内容instructions@JasonGoemaat在我的$scope上设置了一个手表之后,我发现filteredItems是一个子作用域,就像在batarang调试中一样。是否有任何方法可以在其父作用域中包含filteredItems,或者我是否应该将my numberOfPages函数中的$scope.filteredItems更改为对$scope子filteredItems的引用?
$scope.data = { };
<li class="table-row clearfix" 
    ng-repeat="item in ( data.filteredItems = ( instructions | filter:search:strict)) | startFrom:currentPage*showLimit | limitTo:showLimit" 
    ng-include="'js/manuals/manuals-item-instruction-attachment-showInstruction.html'"></li>