在angularJs中执行URL两次而不是一次?

时间:2015-03-07 09:42:16

标签: javascript php angularjs laravel-5

我正在使用angularJs和Rest Web服务开发Web应用程序。我已经编写了用于执行Web服务API和从控制器调用的服务函数。它正在工作但是问题是执行URL两次而不是单次执行。

控制器

invoiceApp.controller('clientController', ['$scope', '$http', 'clientService', function ($scope, $http, clientService) {
        $scope.loadPage = function (url) {
            var request = clientService.list(url);
            request.success(function (data, status) {
                $scope.result = data;
            });
        };
    }]);

服务,

'use strict';

    invoiceApp.factory('clientService', ['$http', function ($http) {
            var url = 'clients';
            return {
                list: function (newUrl) {
                    url = newUrl ? newUrl : url;
                    return $http.get(url);
                }
            };
        }
    ]);

HTML

<table id="dt_basic" class="table table-bordered table-hover" width="100%"  data-ng-init="loadPage()">
.....
...pagination...
  <ul class="pagination pagination-sm pull-right">
                            <li ng-if="result.prev_page_url">
                                <a ng-click="loadPage(result.prev_page_url)" href="javascript:void(0)"><i class="fa fa-angle-left"></i></a>
                            </li>
                            <li ng-if="result.next_page_url">
                                <a ng-click="loadPage(result.next_page_url)" href="javascript:void(0)"><i class="fa fa-angle-right"></i></a>
                            </li>
                        </ul>
</table>

这里当我点击下一页时,它工作正常,但执行URL两次。 enter image description here

1 个答案:

答案 0 :(得分:0)

您应该检查.htaccess检查此link