If you use angular way to modify and update the value of DOM or variables, no additional operations are required.
But if you break away from angular and use code like jquery that is not within the angular system, you need to notify angular of any modifications and let angular get the latest value to reflect it on the page.
So you can use the following method to notify angular
The correct way is... don't change the view manually. Proposal: 1. Try to expose the model, and then modify the model. After the modification, call $scope.$apply(). In addition, in order to avoid various unexpected errors, you can write setTimeout(function(){$scope.$apply()},0) like this. 2. In any case, if you have this need, it must be because of some event, user operation or ajax. Ajax operations can use the $http service provided by Angular. User operations can usually be encapsulated into directives.
If you use
angular way
to modify and update the value of DOM or variables, no additional operations are required.But if you break away from angular and use code like jquery that is not within the angular system, you need to notify angular of any modifications and let angular get the latest value to reflect it on the page.
So you can use the following method to notify angular
The correct way is... don't change the view manually.
Proposal:
1. Try to expose the model, and then modify the model. After the modification, call $scope.$apply(). In addition, in order to avoid various unexpected errors, you can write setTimeout(function(){$scope.$apply()},0) like this.
2. In any case, if you have this need, it must be because of some event, user operation or ajax. Ajax operations can use the $http service provided by Angular. User operations can usually be encapsulated into directives.