Unknown provider: pagingParamsProvider <- pagingParams In ResultAnalysisDetailController

Here is my controller . pagingParams is working fine with other jhipster generated controller .But in my controller it is giving unknown provider ,

(function() {
    'use strict';

    angular
        .module('netCopOnlineExamApp')
        .controller('ResultAnalysisDetailController', ResultAnalysisDetailController);

    ResultAnalysisDetailController.$inject = ['$scope', '$state', 'DataUtils','ResultAnalysis','Exam','DateUtils','ParseLinks','paginationConstants','pagingParams'];

    function ResultAnalysisDetailController($scope, $state, DataUtils, ResultAnalysis ,Exam, DateUtils,ParseLinks, paginationConstants, pagingParams) {

        var vm = this;
        vm.loadPage = loadPage;
        vm.predicate = pagingParams.predicate;
        vm.reverse = pagingParams.ascending;
        vm.transition = transition;
        vm.itemsPerPage = paginationConstants.itemsPerPage;
        vm.refreshExamPackages=refreshExamPackages;
        vm.refreshExams =refreshExams;
        vm.selectedPackageChanged = selectedPackageChanged;
        vm.selectedExamChanged = selectedExamChanged;
        vm.datePickerOpenStatus = {};
        vm.openCalendar = openCalendar;
        vm.getDetails = getDetails;
        vm.searchQuery = pagingParams.search;
        vm.currentSearch = pagingParams.search;

       function refreshExamPackages(select){
         if(select.search !== null && select.search !==''){
            var searchQuery=select.search ;
            vm.examPackages=ResultAnalysis.getTopExamPackages({subString :searchQuery});
         }
       }
       function refreshExams(select){
                if(select.search !== null && select.search !==''){
                   var searchQuery=select.search ;
                   vm.exams=ResultAnalysis.getTopExams({subString :searchQuery});
                }
       }

       function selectedPackageChanged(){
          console.log(vm.examPackage.packageId);
          vm.exams=Exam.getExamsByPackageId({id:vm.examPackage.packageId});

       }
       function selectedExamChanged(){
          console.log(vm.exam.examId)
       }
       vm.datePickerOpenStatus.startDateFrom = false;
       vm.datePickerOpenStatus.startDateTo = false;
       vm.datePickerOpenStatus.endDateFrom =false;
       vm.datePickerOpenStatus.endDateTo =false;

       function openCalendar (date) {
          vm.datePickerOpenStatus[date] = true;
       }

       function getDetails(){
        if(!angular.isUndefinedOrNull(vm.exam.startDateFrom) && !angular.isUndefinedOrNull(vm.exam.startDateTo) &&
        angular.isUndefinedOrNull(vm.exam.endDateFrom) && angular.isUndefinedOrNull(vm.exam.endDateTo)){
                   console.log("START DATE FROM "+vm.exam.startDateFrom);
                   console.log("START DATE TO "+vm.exam.startDateTo);
                   var dateFrom=DateUtils.convertLocalDateToServer(vm.exam.startDateFrom);
                   console.log(dateFrom);
                   var dateTo=DateUtils.convertLocalDateToServer(vm.exam.startDateTo);
                   console.log(dateTo);
                   vm.exams=ResultAnalysis.getExamsStartDateBetween({startDateFrom :dateFrom,startDateTo:dateTo,page: pagingParams.page - 1,size: vm.itemsPerPage,sort: sort()},on);
                   console.log(vm.exams);
        }
        if(!angular.isUndefinedOrNull(vm.exam.endDateFrom) && !angular.isUndefinedOrNull(vm.exam.endDateTo) &&
           angular.isUndefinedOrNull(vm.exam.startDateFrom) && angular.isUndefinedOrNull(vm.exam.startDateTo)){
                   console.log("START DATE FROM "+vm.exam.endDateFrom);
                   console.log("START DATE TO "+vm.exam.endDateTo);
                   var dateFrom=DateUtils.convertLocalDateToServer(vm.exam.endDateFrom);
                   console.log(dateFrom);
                   var dateTo=DateUtils.convertLocalDateToServer(vm.exam.endDateTo);
                   console.log(dateTo);
                   vm.exams=ResultAnalysis.getExamsEndDateBetween({endDateFrom :dateFrom,endDateTo:dateTo});
                   console.log(vm.exams);
        }
        if(!angular.isUndefinedOrNull(vm.exam.startDateFrom) && !angular.isUndefinedOrNull(vm.exam.startDateTo) &&
           !angular.isUndefinedOrNull(vm.exam.endDateFrom) && !angular.isUndefinedOrNull(vm.exam.endDateTo) ){
                    var stardateFrom=DateUtils.convertLocalDateToServer(vm.exam.startDateFrom);
                    console.log(stardateFrom);
                    var startdateTo=DateUtils.convertLocalDateToServer(vm.exam.startDateTo);
                    console.log(startdateTo);
                    var enddateFrom=DateUtils.convertLocalDateToServer(vm.exam.endDateFrom);
                    console.log(enddateFrom);
                    var enddateTo=DateUtils.convertLocalDateToServer(vm.exam.endDateTo);
                    console.log(enddateTo);
                    vm.exams=ResultAnalysis.getExamsStartDateBetweenAndEndDateBetween({startDateFrom :stardateFrom,startDateTo:startdateTo,endDateFrom :enddateFrom,endDateTo:enddateTo});
                    console.log(vm.exams);

           }


        }
        function sort() {
           var result = [vm.predicate + ',' + (vm.reverse ? 'asc' : 'desc')];
           if (vm.predicate !== 'id') {
               result.push('id');
           }
          return result;
        }
         function onSuccess(data, headers) {
         vm.links = ParseLinks.parse(headers('link'));
         vm.totalItems = headers('X-Total-Count');
         vm.queryCount = vm.totalItems;
         vm.exams = data;
         vm.page = pagingParams.page;
        }

        function loadPage(page) {
            vm.page = page;
            vm.transition();
        }

       function transition() {
          $state.transitionTo($state.$current, {
             page: vm.page,
             sort: vm.predicate + ',' + (vm.reverse ? 'asc' : 'desc'),
             search: vm.currentSearch
          });
       }

    }
})();

Controller generated through jhipster has pagingParams injection also,But There is no problem in that files. My controller is giving the above error.

Error: [$injector:unpr] Unknown provider: pagingParamsProvider <- pagingParams <- ResultAnalysisDetailController http://errors.angularjs.org/1.5.8/$injector/unpr?p0=pagingParamsProvider%20%3C-%20pagingParams%20%3C-%20ResultAnalysisDetailController at http://localhost:8080/bower_components/angular/angular.js:68:12 at http://localhost:8080/bower_components/angular/angular.js:4511:19 at Object.getService [as get] (http://localhost:8080/bower_components/angular/angular.js:4664:39) at http://localhost:8080/bower_components/angular/angular.js:4516:45 at getService (http://localhost:8080/bower_components/angular/angular.js:4664:39) at injectionArgs (http://localhost:8080/bower_components/angular/angular.js:4688:58) at Object.instantiate (http://localhost:8080/bower_components/angular/angular.js:4730:18) at $controller (http://localhost:8080/bower_components/angular/angular.js:10369:28) at Object. (http://localhost:8080/bower_components/angular-ui-router/release/angular-ui-router.js:4095:28)

Answers:

Answer

I guess you should resolve pagingParams in your ui-router configuration like:

.state('resultAnalysisDetail', {
        parent: 'entity',
        url: '/resultAnalysisDetail?page&sort&search',
        params: {
            page: {
                value: '1',
                squash: true
            },
            sort: {
                value: 'id,asc',
                squash: true
            },
            search: null
        },
        resolve: {
            pagingParams: ['$stateParams', 'PaginationUtil', function ($stateParams, PaginationUtil) {
                return {
                    page: PaginationUtil.parsePage($stateParams.page),
                    sort: $stateParams.sort,
                    predicate: PaginationUtil.parsePredicate($stateParams.sort),
                    ascending: PaginationUtil.parseAscending($stateParams.sort),
                    search: $stateParams.search
                };
            }]
        }
    })
Answer

try to put controller like below

   angular
        .module('netCopOnlineExamApp',[])
        .controller('ResultAnalysisDetailController', [ResultAnalysisDetailController]);

i hope this will work.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.