angular-annotate-asset-pipeline 在 Grails 2 项目中根本不起作用
angular-annotate-asset-pipeline not working at all in a Grails 2 project
我在 Grails 2.4.4 中有一个项目,我也在其中使用 AngularJS。
我决定使用 Asset Pipeline Plugin along with AngularJs Annotate Asset-Pipeline。第一个用于处理、缩小等静态资产(js、css 等),第二个用于在每个因注入而需要它的函数中获取 myFunc.$inject = [...]
"injection" AngularJS 所依赖的依赖项。
根据 AngularJs Annotate Asset-Pipeline it should put the myFunc.$inject=[]
when the war is going to be generated on my js files when required, but the true is different: it is not working at all (I do not see any $inject
in the minified file and the app breaks due to the dependency injection widely discussed on SO (examples: Angularjs error Unknown provider and AngularJS 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";
}
简答:
更改依赖的版本
来自这个:
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 之后,在朋友的帮助下,我得出结论,这个插件的作者只是删除了其中的逻辑。
这意味着现在(2001 年 5 月 25 日)使用此插件的当前版本 (2.4.1) 没有人能够按预期使用它。
所以,如果有人遇到同样的问题,应该使用我能够成功使用的最新版本 1.1.3。
我在 Grails 2.4.4 中有一个项目,我也在其中使用 AngularJS。
我决定使用 Asset Pipeline Plugin along with AngularJs Annotate Asset-Pipeline。第一个用于处理、缩小等静态资产(js、css 等),第二个用于在每个因注入而需要它的函数中获取 myFunc.$inject = [...]
"injection" AngularJS 所依赖的依赖项。
根据 AngularJs Annotate Asset-Pipeline it should put the myFunc.$inject=[]
when the war is going to be generated on my js files when required, but the true is different: it is not working at all (I do not see any $inject
in the minified file and the app breaks due to the dependency injection widely discussed on SO (examples: Angularjs error Unknown provider and AngularJS 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";
}
简答:
更改依赖的版本
来自这个:
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 之后,在朋友的帮助下,我得出结论,这个插件的作者只是删除了其中的逻辑。
这意味着现在(2001 年 5 月 25 日)使用此插件的当前版本 (2.4.1) 没有人能够按预期使用它。
所以,如果有人遇到同样的问题,应该使用我能够成功使用的最新版本 1.1.3。