<p ng-show="smsSent">
<timer interval="1000" countdown="60" end-time="0" finish-callback="smsSent=!smsSent">{{seconds}}</timer>
</p>
I want to call finish-callback after the timer countdown ends, and then the value of smsSent is inverted, so <p ng-show="smsSent">
this p will be hidden. The problem is... now that the countdown reaches 0 , I observed that the value of smsSent has indeed changed, but <p ng-show="smsSent">
this p is not hidden, which means there is no refresh attempt. Please help, how can I hide that p
PHP中文网2017-05-15 17:07:21
Thank you for the invitation. Can you provide how to write the timer command, or give a link to jsbin or jsfiddle.net to reproduce it. The information currently provided is that the value has been changed, but the Dom is not rendered. I think you can trigger the dirty check in finish-callback $apply
或者 $evalAsync
.
------------------ dividing line ----------------
Find the plug-in you mentioned https://github.com/siddii/ang... , I will make a pull request soon, so you don’t need to actively trigger it in finish-callback $apply
.
------------------Separating line----------------
https://github.com/siddii/ang. ..
The request has been pulled, mainly the following paragraph. When $scope.finishCallback is called, the dirty check loop is actively triggered
if($scope.finishCallback) {
- $scope.$eval($scope.finishCallback);
+ if ($rootScope.$$phase) {
+ $scope.$evalAsync($scope.finishCallback);
+ } else {
+ $scope.$apply($scope.finishCallback);
+ }
}