marmelab / ng-admin

Add an AngularJS admin GUI to any RESTful API
http://ng-admin-book.marmelab.com/
MIT License
3.95k stars 725 forks source link

Unknown provider: totalItemsProvider <- totalItems <- ListController #1343

Open collinforrester opened 7 years ago

collinforrester commented 7 years ago

Scope

If you have a usage question, please ask on StackOverflow or Gitter (live chat)

This form is for reporting bugs in or adding enhancements to ng-admin.

Prerequisites

Description

Version: 1.0.6 Angular: 1.6.x and 1.5.x

Any entity list view throws the error Unknown provider: totalItemsProvider <- totalItems <- ListController (only code in the project is below).

var admin = nga.application('My First Admin')
    .baseApiUrl('http://jsonplaceholder.typicode.com/'); // main API endpoint
  // create a user entity
  // the API endpoint for this entity will be 'http://jsonplaceholder.typicode.com/users/:id
  var user = nga.entity('users');
  // set the fields of the user entity list view
  user.listView().fields([
      nga.field('name'),
      nga.field('username'),
      nga.field('email')
  ]);
  // add the user entity to the admin application
  admin.addEntity(user);
  // attach the admin application to the DOM and execute it
  nga.configure(admin);

Steps to Reproduce

Unfortunately I can't get the error to reproduce in plunkr because I don't know if its related to webpack or an angular version problem with this library.

I'm posting here so that I hope someone sees this and has come across this before.

Doing some digging....

I assume it comes from this controller function ListController($scope, $stateParams, $location, $anchorScroll, ReadQueries, progression, view, dataStore, totalItems).

The only place I can find a totalItems resolver is here inside of ReadQueries:

return this.getRawValues(view.entity, view.name(), view.type, page, view.perPage(), allFilterValues, view.filters(), sortField, sortDir, url).then(function (values) {
                return {
                    data: values.data,
                    totalItems: values.totalCount || values.headers('X-Total-Count') || values.data.length
                };
            });

and here inside of routing.js

totalItems: ['response', function (response) {
                        return response.totalItems;
                    }],

If I put a breakpoint on either one, it never gets hit and the error gets thrown before.

Do we have any example apps of angular 1.5.x or 1.6.x using latest webpack? Maybe I'm missing something there.

collinforrester commented 7 years ago

Still narrowing it down... but I think my suspicions were right - When I link to https://cdn.jsdelivr.net/npm/ng-admin@1.0.6/build/ng-admin.min.js using a regular Githubissues.

  • Githubissues is a development platform for aggregating issues.