vendredi 14 septembre 2018

How to Fix angular.min.js:108 TypeError: Cannot read property 'length' of undefined error is showing Angular js pagination

i am new angularJs now and doing task of pagination, using simplePagination library for doing this stuff every thing configured and working fine but here when inspect Element in browser it is showing

 angular.min.js:108 TypeError: Cannot read property 'length' of undefined
    at b.$scope.numberOfPages (demoController.js:22)
    at fn (eval at compile (angular.min.js:212), <anonymous>:4:230)
    at Object.get (angular.min.js:116)
    at n.$digest (angular.min.js:132)
    at n.$apply (angular.min.js:135)
    at l (angular.min.js:87)
    at F (angular.min.js:91)

Like this here i am using model one is service and controller demo.service

demoService.getTxn = function(scope) {
        $http.get(Commerce.root + '/user/getaccount').success(function(data, status, headers, config) {
            scope.inProgress = false;   
           scope.getname = data.nameList.length != 0 ? data.nameList : false;
        }).error(function(data, status, headers, config) {
            displayMessage(scope, Commerce.message.serverCommunicationError);
        });
    }

and controller code is

demo.Controller

 $scope.currentUser = Commerce.User;
    $scope.currentPage = 0;
    $scope.pageSize = 10;
    $scope.currentPageOrders = 0;
    $scope.pageSizeOrders = 10;


    $scope.initUsers = function() {
        $scope.inProgress = true;
        demoService.getTxn($scope);
    }

    $scope.numberOfPages=function(){
        return Math.ceil($scope.getTxn.length/$scope.pageSize);
    }

please help me to fix this issue .




Aucun commentaire:

Enregistrer un commentaire