S
S
Sergey Nikolaev2015-08-14 14:26:58
JavaScript
Sergey Nikolaev, 2015-08-14 14:26:58

How to correctly update the time in an Angular page?

There is this conclusion:

<tr ng-repeat="item in items">
{{item.date | fromNow}} 
</tr>

fromNow - a filter that converts the date in to "3 minutes ago", etc.
How to force Angular to update the time in the table as intelligently as possible.
$apply() and $digest() didn't help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Sosnovsky, 2015-08-14
@sosnovskyas

I had similar problems with the authorization status when it was necessary to display the logout button using ng-if and for some reason this happened only after the page was refreshed.
but when i wrapped the controller method into a function

o.status = function () {
    auth.status;
   }

and used like this
<div ng-controller="userController as uc">
    <div ng-if="uc.status"> 
   </div>
</div>

everything began to work asynchronously, as it should, immediately after the authorization event in the factory.
maybe it will help you)

S
Sergey, 2015-08-14
Protko @Fesor

$apply() and $digest() didn't help

they just need to be run once in a while.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question