Minification is breaking my AngularJs code

后端 未结 2 751
谎友^
谎友^ 2021-01-05 05:42

I\'m using Cassette which uses the Microsoft Ajax Minifier to minify JS. This minifier renames variables, including variables that have special meaning to Angular, such as <

相关标签:
2条回答
  • 2021-01-05 05:56

    I'm not sure when Cassette Added this, but when you create a bundle you can use AddMinified to indicate that the file is as minified as it can be without breaking it (It won't be minified when it's served).

    That being said, it's much better to use angular's array syntax because smaller files are better!

    0 讨论(0)
  • 2021-01-05 05:58

    To prevent code minifiers from destroying your angular application, you have to use the array syntax to define controllers.

    Look at http://odetocode.com/blogs/scott/archive/2013/03/13/angularjs-controllers-dependencies-and-minification.aspx

    (From OP): For reference, here is the changed code:

    angular.module('account-module', [])
        .controller('ForgottenPasswordController', ["$scope", "$http", function ($scope, $http) {
    ...
    }]);
    
    0 讨论(0)
提交回复
热议问题