【问题标题】:AngularJS - Divide a scope data to pagesAngularJS - 将范围数据划分为页面
【发布时间】:2018-08-23 12:50:20
【问题描述】:

我正在使用 angularjs,并且我有一个包含列表的范围($scope = 工作区)。我要做的是在每个页面中显示 5 个元素。

还在页面底部我想创建一个栏,它可以帮助我用下一个 5 渲染到下一页

var SearchResultController = function ($scope, $http, $location, $window) {


    $scope.testVal;
    $scope.GetWorkSpace = function () {

        var jsonObj = {};

        jsonObj["searchText"] = $scope.testVal;


        var config = {
            params: jsonObj,
            headers: { 'Accept': 'application/json' }
        };


        $http.get("api/SearchResult/Search", config).then(function (response) {
            if (response.data != null) {

                $scope.workspace = response.data;

            }
            else
                alert("not found")
        })

    }
     $scope.GetWorkSpace();


}
SearchResultController.$inject = ['$scope', '$http', '$location', '$window'];
<div class="row">

    <div class="col-md-9">
        <div class="dashboard-list-box fl-wrap">
            <div class="dashboard-header fl-wrap">
                <h3>Indox</h3>
            </div>

            <!-- dashboard-list end-->
            <div class="dashboard-list" ng-repeat="ws in workspace">
                <div class="dashboard-message">

                    <div class="dashboard-listing-table-image" style="float:right">
                        <a href="listing-single.html"><img src="../../Images/1.jpg" alt=""></a>


                        <ul class="dashboard-listing-table-opt  fl-wrap">
                            <li><a onclick="window.location.reload()" href="/#/WorkSpace?id={{ws.ID}}" style="margin-left: 30px;">כניסה למתחם</a></li>
                        </ul>
                    </div>
                </div>
                <div class="dashboard-listing-table-text" style="   text-align:right;padding-right: 20px;">
                    <h4 text-align:right;padding-right: 20px;"><a href="listing-single.html">{{ws.Name}}</a></h4>
                    <div class="footer-contacts-widget fl-wrap">

                        <div class="listing-rating card-popup-rainingvis fl-wrap" data-starrating2="5">
                            <span>{{ws.Description}}</span>

                        </div>

                    </div>
                    <table style="float:right; margin-top: 10px">
                        <tr>
                            <td style="color:black;padding-left: 10px;">
                                <a class="enteremail" href="mailto:{{ws.Email}}" target="_self" style="color:black">{{ws.Email}} <i class="fa fa-envelope-o"></i></a>
                            </td>

                            <td style="color:black;padding-left: 10px;">
                                <a href="https://www.google.com/maps/place/{{ws.Address.City}},{{ws.Address.Street}}{{ws.Address.Number}}" target="_blank" style="color:black">{{ws.Address.City}},{{ws.Address.Street}} {{ws.Address.Number}} <i class="fa fa-map-marker"></i></a>
                            </td>

                            <td style="color:black;padding-left: 10px;">
                                <a style="color:black">{{ws.Phone}} <i class="fa fa-phone"></i></a>

                            </td>
                        </tr>
                    </table>


                </div>
            </div>

        </div>

        <!-- dashboard-list end-->
      <div class="pagination">
        <a href="#" class="prevposts-link"><i class="fa fa-caret-left"></i></a>
        <a href="#">1</a>
        <a href="#" class="current-page">2</a>
        <a href="#">3</a>
        <a href="#">4</a>
        <a href="#" class="nextposts-link"><i class="fa fa-caret-right"></i></a>
    </div>
    </div>

    </div>

元素。最好的方法是什么?请帮忙

【问题讨论】:

标签: javascript c# html angularjs asp.net-mvc


【解决方案1】:

有一个名为 ng-paginator 的包,它真的很容易使用(但很丑,可能需要 css 或类似引导程序的主题)。

安装: npm i --save ng-paginator

打包网站: ng-paginator

还有一个很好的例子,使用javascript中的逻辑在这个网站上进行分页:

angularjs-pagination-example-with-logic-like-google

干杯!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-16
    • 2020-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-16
    • 2010-10-12
    • 1970-01-01
    相关资源
    最近更新 更多