1

Is there a better way to handle the angularjs controller constructors that are compiler friendly?

My code keeps looking like this for each controller...

     return app.controller('WorkspaceCtrl', ['$rootScope', '$scope', '$route', 'DashboardModel', 'dashboards', 'reports', 'workspaces', '$modal', 'growl',
           function WorkspaceCtrl($rootScope, $scope, $route, DashboardModel, dashboards, reports, workspaces, $modal, growl) {

            //.. controller code here ...
     }]);

Thanks!

5
  • 2
    If you are referring to the need to annotate dependencies for each controller to work after minification you can use ng-min. It will handle the annotation of dependencies so that your code can be safely minified. Commented Feb 6, 2014 at 22:25
  • @JonathanPalumbo wow...thats exactly what i was looking for! Commented Feb 6, 2014 at 22:33
  • Glad it helped. Posted as answer for future reference. Commented Feb 6, 2014 at 22:37
  • @JonathanPalumbo curious how this would work with requirejs since your paths are already defined and this is changing the output. Commented Feb 6, 2014 at 22:49
  • Not sure I fully understand the question, however I am not experienced with requirejs. Commented Feb 6, 2014 at 23:01

1 Answer 1

2

Use ng-min it will handle the annotation of dependencies so that your code can be safely minified. It is designed to be run as a grunt task as part of your build process.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.