Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 角度ui引导分页,无法设置页面_Angularjs_Twitter Bootstrap_Pagination - Fatal编程技术网

Angularjs 角度ui引导分页,无法设置页面

Angularjs 角度ui引导分页,无法设置页面,angularjs,twitter-bootstrap,pagination,Angularjs,Twitter Bootstrap,Pagination,我正在尝试对从SharePoint中的列表检索项目的应用程序部件使用分页 在App.js中: var app = angular.module('listWebs', ['ui.bootstrap']) .controller('MainCtrl', function ($scope, $q) { jQuery.getScript(layoutsRoot + "SP.Runtime.js", function () { jQuery.getScript(layou

我正在尝试对从SharePoint中的列表检索项目的应用程序部件使用分页

在App.js中:

var app = angular.module('listWebs', ['ui.bootstrap'])
   .controller('MainCtrl', function ($scope, $q) {

jQuery.getScript(layoutsRoot + "SP.Runtime.js", function () {
            jQuery.getScript(layoutsRoot + "sp.js", function () {
                jQuery.getScript(layoutsRoot + "SP.RequestExecutor.js", function () {

                    getWebs()
                        .then(function (result) {

                            $scope.webs = result;

                            //Pagination
                            setPagination(result);

                        });

                });  // End of getscript SP.RequestExecutor.js
            }); // End of getscript SP.js
        }); // End of getscript SP.Runtime.js

function setPagination(result) {
            $scope.totalItems = result.length;
            $scope.currentPage = 1;
            $scope.noOfPages = function () {
                return Math.ceil(result.length / $scope.pageSize);

            };

        }

function getWebs(RETURNS PROMISE AFTER GETTING RESULTS FROM SP LIST)
.....
        <table class="table table-hover">
        <thead>
            <tr class="active">
                <th>
                    Name
                </th>
                <th>
                    Created
                </th>
            </tr>
        </thead>
        <tbody ng-repeat="web in webs | limitTo:pageSize">
            <tr>
                <td>
                   {{web.title}}
                </td>
                <td>
                   {{web.created | date:dateFormat}}
                </td>
            </tr>
        </tbody>
    </table>
    <pagination ng-show="totalItems.length > 0" boundary-links="true" total-items="totalItems" ng-model="currentPage" num-pages="noOfPages" class="pagination-sm" previous-text="&lsaquo;" next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;"></pagination>
在Index.html中:

var app = angular.module('listWebs', ['ui.bootstrap'])
   .controller('MainCtrl', function ($scope, $q) {

jQuery.getScript(layoutsRoot + "SP.Runtime.js", function () {
            jQuery.getScript(layoutsRoot + "sp.js", function () {
                jQuery.getScript(layoutsRoot + "SP.RequestExecutor.js", function () {

                    getWebs()
                        .then(function (result) {

                            $scope.webs = result;

                            //Pagination
                            setPagination(result);

                        });

                });  // End of getscript SP.RequestExecutor.js
            }); // End of getscript SP.js
        }); // End of getscript SP.Runtime.js

function setPagination(result) {
            $scope.totalItems = result.length;
            $scope.currentPage = 1;
            $scope.noOfPages = function () {
                return Math.ceil(result.length / $scope.pageSize);

            };

        }

function getWebs(RETURNS PROMISE AFTER GETTING RESULTS FROM SP LIST)
.....
        <table class="table table-hover">
        <thead>
            <tr class="active">
                <th>
                    Name
                </th>
                <th>
                    Created
                </th>
            </tr>
        </thead>
        <tbody ng-repeat="web in webs | limitTo:pageSize">
            <tr>
                <td>
                   {{web.title}}
                </td>
                <td>
                   {{web.created | date:dateFormat}}
                </td>
            </tr>
        </tbody>
    </table>
    <pagination ng-show="totalItems.length > 0" boundary-links="true" total-items="totalItems" ng-model="currentPage" num-pages="noOfPages" class="pagination-sm" previous-text="&lsaquo;" next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;"></pagination>

名称
创建
{{web.title}
{{web.created}日期:dateFormat}
我不能让它显示2页,有人知道为什么吗?我试过Math.ceil(返回1.2)和固定值(2),但都不起作用。该列表包含6个项目,我将页面大小限制为5(并且它只显示5个项目)

编辑:根据0.6.0的更改日志:“页数不是由页数定义的,而是从每页的项目总数和项目数定义的。如果每页缺少项目,默认值为10。”


因此,它不使用num pages,而是使用总项目和每页项目。我用的是vers。0.11.2.

您能提供一个Plunker吗?重写代码有点困难,我从SharePoint获取所有项目。我注意到一件奇怪的事情:即使我能在我的应用程序中看到分页控件,它也显示了这一点。也许这就是原因?但为什么它会显示它是否是一个“未知元素”?我已经在生成项目的表后面(并且在ng controller=“MainCtrl”)放置了右键。