我们什么时候需要将方法绑定到控制器中的 $scope,我正在处理的方法只是对对象的映射操作。
Example :
$scope.myVar = {};
function myMyObject(x) {
$scope.myVar = {
"xKey":x
}
}
to
$scope.myMyObject = function(x) {
$scope.myVar = {
"xKey":x
}
}
myMyObject(10);
$scope.myMyObject(10);
Is it necessary to bind $scope to myMyObject method here ?