0

我正在尝试按照文档中的说明设置 ng-admin ,但在控制台中出现以下错误:

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)

我的模板是

<!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>

并且admin.js是:

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/');
});

由于我没有设置任何实体,我完全期待其他错误,但我不明白为什么它很难找到AdminDescription提供者。我已经检查并且浏览器正在成功加载所有JS,所以不是因为那个。

4

1 回答 1

1

您可能使用过介于 0.6 和 0.7 之间的中间版本。现在正确的语法是:

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

app.config(function (NgAdminConfigurationProvider) {
    var nga = NgAdminConfigurationProvider;
    var app = nga.application('My backend')
        .baseApiUrl('http://localhost:3000/');
});
于 2015-04-03T13:05:45.063 回答