javascript - 如何在 Pprod 上运行多个 Angular Directive(指令)模块

标签 javascript angularjs jhipster

我正在开发 jhipster 版本 0.7.0,我在我们的 jhipster 应用程序中有多种类型的指令模块。第一个用于索引页面,第二个用于 commmon 指令。

当我们在 Prod profile 上运行时,我得到了一个异常:-

[31mPhantomJS 1.9.7 (Windows 7) ERROR[39m Error: [$injector:nomod] Module 'common-services' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.2.11-build.2192+sha.e2173f9/$injector/nomod?p0=common-services at D:/github_repo/gather-our-code/src/main/webapp/bower_components/angular/angular.js:1531

相同的代码正在开发配置文件..

请尽快帮我解决这个问题

最佳答案

“prod”配置文件使用 JavaScript 缩小(由 Grunt 运行),这将减小 JavaScript 文件的大小。 由于这会修改您的 JavaScript 代码,因此可能会导致问题,具体取决于您编写依赖项注入(inject)代码的方式。 您看过所提供的示例指令了吗?或者在 sample Controller ?您必须以相同的样式编写依赖注入(inject)。

例如,注入(inject) $scope:

jhipsterApp.controller('MainController', ['$scope',
    function ($scope) {
}]);

这将确保缩小过程不会破坏“$scope”变量的依赖注入(inject)。

如果你不能让它工作,你也可以从缩小过程中排除你的文件:这取决于你的负载,但对于大多数应用程序来说,这是多余的。这是在您的 Gruntfile.js 文件中配置的。

关于javascript - 如何在 Pprod 上运行多个 Angular Directive(指令)模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21726619/

相关文章:

javascript - 使用 $httpBackend 捕获各种请求

javascript - 从 javascript 生成 Angular 指令的 html 绑定(bind)模板

javascript - 我如何管理 jhipster 当局的权限?

mysql - JHipster未知数据库连接错误

node.js - 无法安装 jhipster-generator

javascript - 基于列值的超链接弹出消息

javascript - 待办事项列表应用程序的 ReactJS 代码中未定义映射

javascript - jQuery 获取某些子元素的索引并忽略其他子元素

javascript - 无法初始化 Angular 值

javascript - AngularJs promise 返回未定义