習慣沉默2017-05-15 16:57:58
$scope
is a variable provided internally by angular.
scope
Generally refers to concepts such as scope directive service and so on.
In terms of variables
function($scope){
}
function(scope){
}
No difference.
But the scope or $scope object above is an object provided internally by angular. We usually obtain this object through dependency injection. If you display dependencies:
app.controller("MainCtrl",["$scope",function(scopeObject){
}]);
The injected variable name must be $scope, and the formal parameters in the function do not matter.
If it is implicit injection,
app.controller("MainCtrl",function($scope){
});
The function parameter must be $scope
大家讲道理2017-05-15 16:57:58
Following the answer above, the implicitly injected code
app.controller("MainCtrl",function($scope){
});
$scope can be injected through implicit injection, but when compressing js code, variable names are usually replaced with abbreviations such as abc, causing implicit injection to fail. Therefore, display injection is generally used. At this point, whether to use $scope or scope becomes part of the coding specification, and there is no difference.