I am working on a project in Grails 2.4.4 where AngularJS is also being used.
For handling static assets like js, css, etc, I have opted to use the Asset Pipeline Plugin in combination with AngularJs Annotate Asset-Pipeline. The former handles processing and minifying of the static assets, while the latter adds the necessary myFunc.$inject = [...]
annotations for dependency injection which AngularJS relies on.
Despite the documentation of AngularJs Annotate Asset-Pipeline suggesting that it should automatically add the $inject
annotation when generating the war file for my js files as needed, this functionality does not seem to be working as expected. There are no $inject
annotations in the minified files, causing the application to break due to dependency injection errors (such as "Unknown provider").
Below you can find relevant code snippets (if additional information is required, please let me know)
BuildConfig.groovy
compile "org.grails.plugins:asset-pipeline:1.9.9"
compile "org.grails.plugins:angular-annotate-asset-pipeline:2.4.1"
AngularJS controller (example)
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";
}