两种控制器定义之间有什么区别? [英] What's the difference between the two controller definitions?
本文介绍了两种控制器定义之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
运行代码时,选项A
失败,但不确定原因是什么.
When I run the code, Option A
is failed but not sure what the reason is.
angular.module('app').controller('controllerA', function($scope, $http) {
// code
}
angular.module('app').controller('controllerB', ['$scope', '$http', function($scope, $http) {
// code
}]);
我试图在Angular 1.x JSFiddle上对其进行测试,但是它们都可以正常工作. 救救我!
I tried to test it on Angular 1.x JSFiddle, but both of them work well. Help me!
推荐答案
这在缩小过程中有很大的不同.如果使用的是angular.min.js
库,则在生产环境中,选项A
失败.在JSFiddle中,您可能使用angular.js
lib.这就是为什么两种情况都可以工作的原因.
This makes much difference in the minification process. if you are using angular.min.js
library then in the production, option A
fails. in JSFiddle u might use angular.js
lib. That's why both scenarios work.
检查此以获取有关缩小的更多信息
Check this for more information about minification
这篇关于两种控制器定义之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文