【问题标题】:angular-annotate-asset-pipeline not working at all in a Grails 2 projectangular-annotate-asset-pipeline 在 Grails 2 项目中根本不起作用
【发布时间】:2017-10-24 00:17:04
【问题描述】:

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

我决定将Asset Pipeline PluginAngularJs Annotate Asset-Pipeline 一起使用。第一个用于处理、缩小等静态资产(js、css 等),第二个用于在每个需要它的函数中获取 myFunc.$inject = [...]“注入”,因为 AngularJS 依赖注入依赖。

根据AngularJs Annotate Asset-Pipeline 的文档,它应该在需要时将myFunc.$inject=[] 放在我的js 文件上生成战争时,但事实不同:它根本不起作用(我没有看到缩小文件中的任何$inject 并且由于在SO 上广泛讨论的dependency injection 而导致应用程序中断(例如: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 控制器(这只是一个例子)

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";
}

【问题讨论】:

    标签: javascript angularjs grails asset-pipeline annotate-asset-pipeline


    【解决方案1】:

    简答:

    更改依赖的版本

    从此

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

    到这里

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

    长篇大论

    在挖掘AngularJs Annotate Asset-Pipeline之后,在朋友的帮助下,我得出的结论是这个插件的作者只是删除了它里面的逻辑。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-15
      • 2023-04-05
      • 1970-01-01
      • 1970-01-01
      • 2016-05-11
      相关资源
      最近更新 更多