처음 AngularJs를 구현하려고합니다. NgTableParams
데이터를 테이블에 채울 수 있었지만 등의 메서드를 사용하여 던지는 오류가 발생했습니다. 다음 문제는 ng-table
입니다.Angularjs 테이블 매개 변수가 작동하지 않습니까?
1- 그래서 params 메소드를 사용하지 않으면 테이블에 대한 데이터를 얻을 수 있었지만 오류는 $defer.resolve is not a function
입니다.
2는 어떻게 아무것도 내가 아래 코드에서 내 테이블 옵션을 설정 실종, 이러한 문제를 해결하기 위해 내가 오류 can not read page its undefined
어떤 생각을 가지고 PARAMS을 사용하는 경우?
ctrl.js
angular.module('loggingApp').controller('ditTableCtrl', function($scope, DitFactory, $filter, NgTableParams) {
'use strict';
$scope.logs = [];
DitFactory.getLogs().then(function(response) {
$scope.logs = response.data;
console.log($scope.logs);
});
$scope.usersTable = new NgTableParams({
page: 1,
count: 10
}, {
total: $scope.logs.length,
getData: function($defer, params) {
$scope.data = $scope.logs.slice((params.page() - 1) * params.count(), params.page() * params.count());
$defer.resolve($scope.data);
}
});
});
main.html은
<table ng-table="usersTable" class="table table-striped">
<tr ng-repeat="user in data">
<td data-title="'Id'" >
{{user.id}}
</td>
<td data-title="'First Name'" >
{{user.first_name}}
</td>
<td data-title="'Last Name'" >
{{user.last_name}}
</td>
<td data-title="'e-mail'" >
{{user.email}}
</td>
<td data-title="'Country'">
{{user.country}}
</td>
<td data-title="'IP'" >
{{user.ip_address}}
</td>
</tr>
</table>