urish / angular-moment

Moment.JS directives for Angular.JS (timeago and more)
MIT License
2.6k stars 397 forks source link

Time display not updating? #231

Closed chrismanderson closed 8 years ago

chrismanderson commented 8 years ago

With version 0.10.3, and a simple

$scope.message = {
  text: 'hello world!',
  time: new Date()
};

and using

<span>{{message.time | amDateFormat:'dddd, MMMM Do YYYY, h:mm:ss a'}}</span>

I'm not seeing the time actually update, no matter how long I wait. That should be happening by default, right?

urish commented 8 years ago

Hi, the amDateFormat filter does not update automatically. Only the am-time-ago directive does...

chrismanderson commented 8 years ago

Ok, thanks for that info. Obvious feature request, have the filters update too :). Thanks for getting back to me!

urish commented 8 years ago

Unfortunately, in Angular 1.0, filters can't trigger an update, that's the reason am-time-ago was implemented as a directive.

In your case, you can probably work around this by periodically triggering a digest cycle, something like:

setTimeout(function(){$rootScope.$digest();}, 1000);

But this will severely affect performance in larger application.