If I have a directive that responds to the status of a particular attribute on the scope, and I want to change that attribute in my test and verify that it responds correctly, which is the best way of doing that change?
I've seen both these patterns:
scope.$apply(function() {
scope.myAttribute = true;
});
and
scope.myAttribute = true;
scope.$digest();
What is the difference between them, and which is better and why?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…