0

Do I need to use bracket notation for defining the run() block? If i want to minify the javascript files even though run() block is not expecting the any parameters.

here is my code for run block

  app.run(function () {
  $(function () {
    $(document).keydown(function (e) {
      if((e.which || e.keyCode) == 116 || (e.keyCode == 82 && e.ctrlKey)){
        e.preventDefault();
        var path = $state.current.name;
         var subpath = path.split(".");
         if(subpath.length > 1) {
         if (subpath[1] == 'list')
         $state.reload();
         }else
         $state.reload();
      }else {
        return (e.which || e.keyCode) != 116;
      }
    });
  });
});

any help will be appriciated.

3
  • 1
    What happen if you test it? Commented Jul 16, 2016 at 6:25
  • i'm not yet tested , i need some suggestions so.. Commented Jul 16, 2016 at 6:28
  • Is uglification synonymous with minification? If not, is there any point to uglification besides obfuscation? Commented Jul 16, 2016 at 6:36

1 Answer 1

1

If u are injecting any dependencies u need to do dependency annotation(declare the injection using string) before minifying.

In your case looks like u need inject $state, so u'd better have ur code like:

   app.run(['$state',function ($state) {
  $(function () {
    $(document).keydown(function (e) {
      if((e.which || e.keyCode) == 116 || (e.keyCode == 82 && e.ctrlKey)){
        e.preventDefault();
        var path = $state.current.name;
         var subpath = path.split(".");
         if(subpath.length > 1) {
         if (subpath[1] == 'list')
         $state.reload();
         }else
         $state.reload();
      }else {
        return (e.which || e.keyCode) != 116;
      }
    });
  });
}]);

Then u can uglify it safely.

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.