Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

setting a variable in a promise #3

Closed
dylanjha opened this issue Jun 18, 2013 · 4 comments
Closed

setting a variable in a promise #3

dylanjha opened this issue Jun 18, 2013 · 4 comments

Comments

@dylanjha
Copy link

When I'm setting the time variable inside a promise response I get this odd behavior where angular-moment flashes the proper time, then it changes to "a few seconds ago." See here: https://www.dropbox.com/s/lp47wjilap0xpgh/angular-moment.mov

controller:

service.fetchPromise().then(function(resp){
  $scope.time_to_show = new Date("2013-05-24");
}

view:

<span am-time-ago="time_to_show"></span>
@dylanjha
Copy link
Author

I've done a little debugging, not sure what the best fix is, but this some more info if it's useful.

value on line 25 is undefined.
the default moment(undefined) object gets passed to updateTime,
the secondsUntilUpdate is set to 1,

I'm guessing that in between the first call and the timeout angular-moment re-evaluates the directive, value is now the proper Date object, but then the timeout comes by and resets it every second.

@urish
Copy link
Owner

urish commented Jun 19, 2013

Interesting... I suspect that in this case a new timeout is created with the proper value, but then, the old timeout still lives and that's why the flashing occurs.

Can you try to with the latest version I just committed and let me know if it resolves the issue?

@dylanjha
Copy link
Author

fixed! thank you 👍

@urish
Copy link
Owner

urish commented Jun 19, 2013

You welcome :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants