gpt4 book ai didi

javascript - angular-annotate-asset-pipeline 在 Grails 2 项目中根本不起作用

转载 作者:行者123 更新时间:2023-11-29 23:45:58 25 4
gpt4 key购买 nike

我在 Grails 2.4.4 中有一个项目,我也在其中使用了 AngularJS。

我决定使用 Asset Pipeline Plugin连同 AngularJs Annotate Asset-Pipeline .第一个用于处理、缩小等静态 Assets (js、css 等),第二个用于在每个函数中获取 myFunc.$inject = [...]“注入(inject)”由于 AngularJS 所依赖的注入(inject)依赖性,因此需要它。

根据 AngularJs Annotate Asset-Pipeline 的文档它应该在需要时在我的 js 文件上生成 war 时放置 myFunc.$inject=[],但真实情况不同:它根本不起作用(我没有看到由于在 SO 上广泛讨论的 dependency injection,缩小文件中的任何 $inject 和应用程序中断(示例:Angularjs error Unknown providerAngularJS Error: $injector:unpr Unknown Provider)

下面是相关代码(如果需要其他代码,请告诉我)

BuildConfig.groovy

compile "org.grails.plugins:asset-pipeline:1.9.9"
compile "org.grails.plugins:angular-annotate-asset-pipeline:2.4.1"

AngularJS Controller (这只是一个例子)

angular
.module('app', [])
.controller('myCtrl', myCtrl);

/*@ngInject*/ // << --- did not work!
function myCtrl ($scope){

//I also used the "ngIngect"; alternative here and it did not work either!

$scope.myVar = "sample text";
}

最佳答案

简答:

改变依赖的版本

来自这个:

compile "org.grails.plugins:angular-annotate-asset-pipeline:2.4.1"

对此:

编译“org.grails.plugins:angular-annotate-asset-pipeline:1.1.3”

说来话长

深入研究 AngularJs Annotate Asset-Pipeline 之后, 在 friend 的帮助下,我得出的结论是,这个插件的作者只是删除了其中的逻辑。

这意味着现在(2001 年 5 月 25 日)使用此插件的当前版本 (2.4.1) 没有人能够按预期使用它。

因此,如果有人遇到同样的问题,应该改用我能够成功使用的最新版本 1.1.3。

关于javascript - angular-annotate-asset-pipeline 在 Grails 2 项目中根本不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44145062/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com