Mój niestandardowy filtr startFrom
podaje błąd.Filtr niestandardowy z napisem "Nie można odczytać właściwości" z undefined "w AngularJS
app.filter('startFrom', function() {
return function(input, start) {
start = +start; //parse to int
return input.slice(start);
}
});
app.controller("PostCtrl", function($scope, $http) {
$scope.currentPage = 0;
$scope.pageSize = 10;
$scope.hidePagination = true;
$scope.search = function() {
$http.get('someurl').then(sucesscalback,errorcalback);
function sucesscalback(response)
{
$scope.hidePagination = false;
console.log("Success:");
console.log(response.data.records);
$scope.posts = response.data;
$scope.numberOfPages=Math.ceil($scope.posts.records.length/$scope.pageSize);
alert($scope.numberOfPages);
}
function errorcalback(failure)
{
console.log("Error:");
console.log(failure);
}
tak. ale dlaczego dane wejściowe są niezdefiniowane/nie istnieją? – Fahad
@Fahad, ponieważ cykl kątowy $ digest trwa, zanim wartość zostanie wypełniona ze sterownika. – m59
o tak ... czy jest jakieś rozwiązanie tego problemu? – Fahad