0

I am trying to set up ng-admin as described in the docs, but I am getting the following error in the console:

Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:unpr] Unknown provider: AdminDescription
http://errors.angularjs.org/1.3.15/$injector/unpr?p0=AdminDescription
    at REGEX_STRING_REGEXP (http://localhost:3000/libs/angular/angular.js:63:12)
    at http://localhost:3000/libs/angular/angular.js:4015:19
    at getService (http://localhost:3000/libs/angular/angular.js:4162:39)
    at Object.invoke (http://localhost:3000/libs/angular/angular.js:4194:13)
    at runInvokeQueue (http://localhost:3000/libs/angular/angular.js:4109:35)
    at http://localhost:3000/libs/angular/angular.js:4118:11
    at forEach (http://localhost:3000/libs/angular/angular.js:323:20)
    at loadModules (http://localhost:3000/libs/angular/angular.js:4099:5)
    at createInjector (http://localhost:3000/libs/angular/angular.js:4025:11)
    at doBootstrap (http://localhost:3000/libs/angular/angular.js:1452:20)

My template is

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Admin</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="libs/ng-admin/build/ng-admin.min.css">
  </head>
  <body ng-app="app">
    <div class="container-fluid">
      <div ui-view></div>
    </div>

    <script src="libs/angular/angular.js"></script>
    <script src="libs/ng-admin/build/ng-admin.min.js"></script>
    <script src="admin.js"></script>
  </body>
</html>

And admin.js is:

var app = angular.module('app', ['ng-admin']);

app.config(function (AdminDescription, NgAdminProvider) {
    var nga = AdminDescription;
    var app = nga.application('My backend')
        .baseApiUrl('http://localhost:3000/');
});

Since I have not set up any entities, I fully expect other errors, but I can't see why it would have trouble finding the AdminDescription provider. I have checked and the browser is loading all the JS successfully, so it's not because of that.

aquavitae
  • 17,414
  • 11
  • 63
  • 106

1 Answers1

1

You've probably used an intermediate version between 0.6 and 0.7. the right syntax is now:

var app = angular.module('app', ['ng-admin']);

app.config(function (NgAdminConfigurationProvider) {
    var nga = NgAdminConfigurationProvider;
    var app = nga.application('My backend')
        .baseApiUrl('http://localhost:3000/');
});
François Zaninotto
  • 7,068
  • 2
  • 35
  • 56