0

我从 MEAN Stack 开始,我正在努力做一些我确信它非常基本的事情。

我正在尝试注入其可下载库提供的 draw2d 新实例。

我一直有:“ncaught 错误:[$injector:modulerr] 无法实例化模块意味着由于:错误:[$injector:modulerr] 无法实例化模块 draw2d 由于:错误:[$injector:nomod] 模块'draw2d'不可用!您拼错了模块名称或忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。”

来自:


模块/核心/客户端/app/config.js

  var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ngMessages', 'ui.router', 'ui.bootstrap', 'ui.utils', 'angularFileUpload', 'draw2d'];

这是其他文件:


模块/mymodule/client/controllers/projects.client.controller.js

...
ProjectsController.$inject = ['$scope', '$state', 'Authentication', 'projectResolve', 'draw2d'];

function ProjectsController ($scope, $state, Authentication, project, draw2d) {
    $scope.$on('$viewContentLoaded', function(event){
        var canvas = new draw2d.create('canvas');
    }
);
...

模块/mymodule/client/services/draw2d.client.service.js

(function () {
  'use strict';

  angular
    .module('mymodule')
    .factory('draw2d', draw2d);

  function draw2d() {
    return {
      create: function (divName) {
        var Draw2d = draw2d;
        return new Draw2d().Canvas('canvas');
      }
    };
  }
})();

该模块的包位于“public/lib/vendors/draw2d”

配置/资产/default.js

'use strict';

module.exports = {
  client: {
    lib: {
      css: [
        'public/lib/bootstrap/dist/css/bootstrap.css',
        'public/lib/bootstrap/dist/css/bootstrap-theme.css'
      ],
      js: [
        'public/lib/vendors/draw2d/lib/canvg.js',
        'public/lib/vendors/draw2d/lib/Class.js',
        'public/lib/vendors/draw2d/lib/jquery-1.10.2.min.js',
        'public/lib/vendors/draw2d/lib/jquery-touch_punch.js',
        'public/lib/vendors/draw2d/lib/jquery.autoresize.js',
        'public/lib/vendors/draw2d/lib/jquery.contextmenu.js',
        'public/lib/vendors/draw2d/lib/json2.js',
        'public/lib/vendors/draw2d/lib/pathfinding-browser.min.js',
        'public/lib/vendors/draw2d/lib/raphael.js',
        'public/lib/vendors/draw2d/lib/rgbcolor.js',
        'public/lib/vendors/draw2d/lib/shifty.js',
        'public/lib/vendors/draw2d/lib/StackBlur.js',
        'public/lib/vendors/draw2d/src/draw2d.js',

        'public/lib/angular/angular.js',
        'public/lib/angular-resource/angular-resource.js',
        'public/lib/angular-animate/angular-animate.js',
        'public/lib/angular-messages/angular-messages.js',
        'public/lib/angular-ui-router/release/angular-ui-router.js',
        'public/lib/angular-ui-utils/ui-utils.js',
        'public/lib/angular-bootstrap/ui-bootstrap-tpls.js',
        'public/lib/angular-file-upload/angular-file-upload.js',
        'public/lib/owasp-password-strength-test/owasp-password-strength-test.js'
      ],
      tests: ['public/lib/angular-mocks/angular-mocks.js']
    },
    css: [
      'modules/*/client/css/*.css',
      'public/lib/vendors/draw2d/css/contextmenu.css'
    ],
    less: [
      'modules/*/client/less/*.less'
    ],
    sass: [
      'modules/*/client/scss/*.scss'
    ],
    js: [
      'modules/core/client/app/config.js',
      'modules/core/client/app/init.js',
      'modules/*/client/*.js',
      'modules/*/client/**/*.js'
    ],
    views: ['modules/*/client/views/**/*.html'],
    templates: ['build/templates.js']
  },
  server: {
    gruntConfig: 'gruntfile.js',
    gulpConfig: 'gulpfile.js',
    allJS: ['server.js', 'config/**/*.js', 'modules/*/server/**/*.js'],
    models: 'modules/*/server/models/**/*.js',
    routes: ['modules/!(core)/server/routes/**/*.js', 'modules/core/server/routes/**/*.js'],
    sockets: 'modules/*/server/sockets/**/*.js',
    config: 'modules/*/server/config/*.js',
    policies: 'modules/*/server/policies/*.js',
    views: 'modules/*/server/views/*.html'
  }
};

模块/mymodule/core.client.module.js

(function (app) {
    'use strict';

    app.registerModule('mymodule', ['core']);// The core module is required for special route handling; see /core/client/config/core.client.routes
    app.registerModule('mymodule.services');
    app.registerModule('kmymodule.routes', ['ui.router', 'mymodule.services']);
})(ApplicationConfiguration);

你能帮我解释一下我错过了什么吗?非常感谢您的宝贵帮助!:)

4

1 回答 1

0

哦,男孩,我发现是什么导致了这个错误。我不必在项目依赖项中声明它。现在工作...

于 2016-03-15T10:45:44.813 回答