ng-table

时间:2017-07-21 14:13:30

标签: html angularjs

我是Ng-table的新手并且能够显示这些值。在尝试执行排序和分页等功能时,它显示错误。类似于Params未定义'。任何人都可以帮忙解决这个问题吗?



    .controller('reportsCtrl', function ($scope, $http, $filter, NgTableParams) {

        // alert()
        $http.get('data/data.json')
            .success(function (data, status) {
                $scope.accounts = data;
                //alert(data)
                $scope.accountTableParams = new NgTableParams({
                    page: 1,
                    count: 3,
                    getData: getData(),
                    sorting: {
                        accountName: "asc"
                    }
                }, {
                    total: $scope.accounts.length,

                });

            });

        function getData($defer, params) {
            $scope.data = $scope.accounts.slice((params.page() - 1) * params.count(), params.page() * params.count());
            $defer.resolve($scope.data);
            alert($scope.accounts.length)

        }





    });

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div class="row" ng-controller="reportsCtrl">
    <table class="table" ng-table="accountTableParams">
        <thead>
            <tr>
                <th></th>
                <th>Account Name</th>
                <th>Status </th>
                <th>Industry </th>
                <th>Contacts</th>
                <th>Account Owner</th>
                <th>Account Type</th>
                <th>Platform</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="person in accounts">
                <td>
                    {{$index + 1}}
                </td>
                <td>
                    <a ui-sref="view.accountDetails" href="#">  {{person.accountName}}</a>
                </td>
                <td sortable="'status'">
                    {{person.status}}
                </td>
                <td sortable="'industry'">
                    {{person.industry}}
                </td>
                <td sortable="'contacts'">
                    {{person.contacts}}
                </td>
                <td sortable="'accountOwner'">
                    {{person.accountOwner}}
                </td>
                <td sortable="'accountType'">
                    {{person.accountType}}
                </td>
                <td sortable="'platform'">
                    {{person.platform}}
                </td>
                <td data-title="''">

                    <div class="btn-group">
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    <span class="">...</span>
    <span class="sr-only">Toggle Dropdown</span>
  </button>
                        <ul class="dropdown-menu">
                            <li><a href="#">Edit</a></li>
                            <li><a href="#">+Add a Contact</a></li>
                            <li><a href="#">+Add an Opportunity</a></li>
                        </ul>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
&#13;
&#13;
&#13;

我的data.json文件在哪里,{         &#34; accountName&#34;:&#34; ST Thomas&#34;,         &#34; status&#34;:&#34; sdfdf&#34;,         &#34;行业&#34;:&#34; dfggg&#34;,         &#34;联系人&#34;:33,         &#34; accountOwner&#34;:&#34; ddd&#34;,         &#34; accountType&#34;:&#34; dd&#34;,         &#34; platform&#34;:&#34; Tag&#34;,         &#34;空&#34;:&#34;&#34;

},

0 个答案:

没有答案