我想检查一下范围中的每一个变化,我尝试了以下几点:
$scope.$watch('$scope', function(newValue) {
console.log ("$scope's NewValue", newValue);
}, true);我收到了日志信息:
$scope's NewValue undefined不管怎么说,这是有可能的吗?
发布于 2015-12-15 10:08:38
我真的建议你不要这么做。在你的申请中它会有很高的成本。
$scope.$watch(function() { // First function must return the object that you want to watch.
return $scope;
},
function(newValue, oldValue) { // This is a callback executed everytime your $scope will change
console.log("$scope's NewValue : ", newValue); // You should rather use $log if you want to unit test your code one day
},
true // Needed to tell angular to watch deeply inside $scope (every sub item).
);https://stackoverflow.com/questions/34285951
复制相似问题