是角度新手,尝试使用ng-table,
我的控制器:
var application = angular.module('helloWorldApplication', [ 'ngRoute',
'ngTable' ]);
application.config([ '$routeProvider', function($routeProvider) {
$routeProvider.when('/', {
template : 'Welcome User!'
}).when('/anotherPage', {
template : 'Welcome user, another page!'
}).otherwise({
redirectTo : '/'
});
} ]);
var custUrl = "http://localhost:8080/TaskManagment/tasks_example.txt";
application. controller ('getCustomers', ['$scope', '$http', 'NgTableParams',
function($scope, $http, NgTableParams) {
var tableData = [];
$scope.tableParams = new NgTableParams({
page:1,
count:6
}, {
total: tableData.length,
getData : function($defer,params){
$http.get(custUrl).then(function(response) {
tableData = response.data.records;
console.log('tableData inside getData:');
console.log(tableData);
console.log('params inside getData:');
console.log(params);
$scope.data = tableData.slice((params.page() - 1) * params.count(), params.page() * params.count());
$defer.resolve($scope.data);
params.total(tableData.length);
});
}
});
}]);
我遇到异常
TypeError:无法获取未定义的属性“page”或null 参考
有人可以告诉我这里有什么问题。