2
How to do a refresh only on an "ng-Binding" and not on the page, to get the current date via Angularjs?
I have the following code:
function updateTime() {
scope.time = new Date();
}
But I need to do a refresh, so that it is synchronized with the logic, that is: Whenever update the minute, in my html it also updates.
<span>{{time|date: 'hh:mm a'}}</span>
I saw something about the $interval
but so far I have not succeeded, if someone can explain how to use the same, or another way to get the same result, I am grateful.
great tip, that’s exactly what I wanted. But what would be the difference of using the $timeout and the $interval you could tell me?
– Edmo
The
$timeout
delays the execution of the function, while the$interval
runs it repeatedly. That is, the first executes the function after the specified interval, while the second executes the function at each interval.– Guilherme Portela
thanks for the explanation. I managed to solve my problem with the $interval. A hug.
– Edmo