Minification is breaking my AngularJs code

后端 未结 2 752
谎友^
谎友^ 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: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) {
    ...
    }]);
    

提交回复
热议问题