The pagingParamsProvider is not recognized in the ResultAnalysisDetailController, which is causing an error

My generated controller is causing an issue with the pagingParams injection. Although other jhipster controllers work fine, mine throws an error for 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
          });
       }

    }
})();

While controllers generated through jhipster include pagingParams injection without any problem, my specific controller encounters the mentioned 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)

Answer №1

To properly configure your ui-router settings, make sure to address the pagingParams as shown below:

.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 №2

Consider using the following controller structure:

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

This should hopefully resolve any issues you are facing.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for comprehending the Executor example in Java's API documentation

Could someone please provide a thorough explanation of the following code snippet? class SerialExecutor implements Executor { final Queue<Runnable> tasks = new ArrayDeque<Runnable>(); final Executor executor; Runnable active; Seri ...

Java method that retrieves numbers lower than the average

I was given a project where I needed to create an array for 10 variables based on user input and then output the average of those numbers along with listing the numbers below the average. While I successfully calculated the average, my code to display th ...

ESLint has detected a potential race condition where the `user.registered` variable could be reassigned using an outdated value. This issue is flagged by the `require-atomic-updates` rule

I have developed an asynchronous function which looks like this: let saveUser = async function(user){ await Database.saveUser(user); if (!user.active) { user.active = true; //storedUs ...

Calculating the bounding box of an Object3D with BufferGeometry in Three.js using JavaScript

Having an Object3D with various levels of children (more Object3Ds or Meshes/Lines), I am trying to compute a bounding box of the object and all its descendants similar to the setFromObject() method in the Box3 class. Unfortunately, I can't utilize t ...

Can data be hardcoded into Array objects in Java?

Could someone please help me correct this code snippet? List<Object> objectList = new ArrayList<Object>(); objectList.addAll(Arrays.asList(["206C(1)", "CG", 1],["206C(1)", "SG", 1])); Once the data is st ...

PhongMaterial designed specifically for rendering InstancedBufferGeometry

I am working on creating a scene with thousands of simple meshes, and I decided to implement InstancedBufferGeometry for better performance. Most of my code is based on the example provided here: Although instancing works well, it seems to only function p ...

How to focus on a dynamically changing input box in Vue

In my form, users can input an email address and click a plus button to add another input box for a new email address. These input boxes are created by iterating over an array, so when the user clicks on the plus icon, a new entry is added to the array. W ...

Is it possible to trigger a JavaScript function and an AJAX command with just one button click?

I'm looking to achieve a specific functionality using one button within a form. The requirements are as follows: 1) When the button is clicked, it should trigger a JavaScript function that performs animations such as fadeout and fadein. 2) Following ...

Picking out specific elements from a component that is rendered multiple times in a React application

One of the challenges I face involves a component called card, which is rendered multiple times with different data. Here's how it looks: { this.state.response.reminders.map((item,i=0) =>{ return <Card key={i++} reminder={item} deleteRem={th ...

Exploring the Exciting Possibilities of Combining Rails 4

I feel like I must be doing something really silly or foolish here. I've been banging my head against the wall all day trying to make jQueryUI work in my Rails 4.2.1 application, but for some reason, it's just not happening. It seems like such a ...

Retrieve information from a controller and pass it to a Component in AngularJs

Having an issue with passing data from a controller to a component in AngularJs. The data is successfully passed to the template component, but it shows up as undefined in the controller! See below for my code snippets. The controller angular.module(&a ...

Establishing the ISO date time to the beginning of the day

When working with a Date retrieved from a Mongo query in ISO format, the goal is to compare it with today's date. To accomplish this, a new Date is created and its time is set to zero: var today = new Date(); today.setHours(0,0,0,0); //Sat Jan 20 201 ...

Having trouble with test coverage in Mocha using Blanket?

I have a Node application that I want to test and generate a coverage report for. I followed the steps outlined in the Getting Started Guide, but unfortunately, it doesn't seem to be working correctly. In my source code file named src/two.js: var tw ...

Issue with jQuery click event not triggering on dynamically created input boxes for removal

Having some trouble with the remove buttons not working on dynamically generated text boxes. The click function doesn't seem to be triggering, and I'm a bit stuck. Any ideas on what might be causing this issue? Take a look at the following co ...

How can I determine if a variable is a primitive type and not an object?

Can a variable be tested to determine if it is a primitive data type? I've come across many inquiries about testing a variable to check if it is an object, but not specifically for a primitive type. This inquiry is purely academic, as I do not requi ...

Transforming JSON data in Node JS according to the city

I currently have a JSON object that contains information about various products and their details in different cities. const data = [ { "city name": "Chennai", "product name": "Apple", ...

JQuery loader & amazing animations

I have implemented the wow.js plugin along with a jQuery preload tutorial from here. Although the preloader works fine, I am facing an issue where the animation by wow.js starts before all the elements on the page are preloaded. I am looking to modify my ...

Issue with event stopPropagation() or stopImmediatePropagation() not functioning in Bootstrap 5

I'm attempting to implement a span tag with a click event within my according header, however, I don't want to display or collapse my according element. So, I tried using stopPropagation() and stopImmediatePropagation(), but neither worked. H ...

The $().bind function will not function properly unless the document is fully loaded

Do I need to include $(document).ready() with $().bind? Here is the HTML portion: <head> <script type="text/javascript" src="jquery-1.10.2.min.js"></script> <script type="text/javascript" src=&quo ...