![](/img/trans.png)
[英]Is there any difference in function between these two Angular controllers
[英]What is the difference between these two angular js controllers?
在声明控制器时,我通常会看到以下内容:
University.controller('ClassroomController', function($scope){
//do stuff
});
与以下内容相比有什么区别:
var classroomController = function ($scope){
//do stuff
}
University.controller('ClassroomController',['$scope',classroomController])
这些教程似乎并未说明第二种声明类型的优点是什么。
如果缩小js,第一种语法会中断。 例如,Angular会尝试找到$timeout
但会找到a
为了避免这种情况,您必须显式声明或内联依赖项
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.