AngularJS not working in release mode (minified)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 04:34:01
j.wittwer

ASP.NET MVC minifies javascript files when the compilation debug value is set to "false". The angular tutorial includes this note about minification:

Since Angular infers the controller's dependencies from the names of arguments to the controller's constructor function, if you were to minify the JavaScript code for [your] controller, all of its function arguments would be minified as well, and the dependency injector would not be able to identify services correctly.

The most common technique to overcome this problem is inline bracket notation, like:

phonecatApp.controller('PhoneListCtrl', ['$scope', '$http', function($scope, $http) {...}]);

This SO question explains the importance of minification safe syntax: Angularjs minify best practice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!