You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
I have a google map where I click a unit. When I click a unit I get some data about the unit from a REST through a service. I then get StartToday witch is in seconds. I then want to show it as HH:mm:ss. My StartToday returns 360.
{{unit.StartToday * 1000}} // Works is 360000
{{360000 | date: "HH:mm:ss"}} // Works is 01:06:00
{{unit.StartToday * 1000 | date: "HH:mm:ss"}} // Does not work
I get this error:
EXCEPTION: Error in ./MapComponent class MapComponent - inline template:11:12 caused by: Invalid argument 'NaN' for pipe 'DatePipe' ORIGINAL EXCEPTION: Invalid argument 'NaN' for pipe 'DatePipe'
The problem is that you are using an async service so your get 360000 value only after some time, asynchronously. Initially your value is NaN and hence the error. Check this plunk and see the flash of NaN -> 3600.
We could change the date pipe to ignore NaN (@DzmitryShylovich, WDYT?) but the crux of the problem is that you are passing NaN to the pipe and this is an invalid argument as clearly stated in the error message.
Activity
DzmitryShylovich commentedon Jan 25, 2017
Pls provide a plunkr with reproduction
D-Thrane commentedon Jan 26, 2017
http://plnkr.co/edit/SpQP2pxmOXsn2y3ufOoX?p=preview
pkozlowski-opensource commentedon Jan 26, 2017
The problem is that you are using an async service so your get
360000value only after some time, asynchronously. Initially your value isNaNand hence the error. Check this plunk and see the flash ofNaN->3600.We could change the date pipe to ignore
NaN(@DzmitryShylovich, WDYT?) but the crux of the problem is that you are passing NaN to the pipe and this is an invalid argument as clearly stated in the error message.DzmitryShylovich commentedon Jan 26, 2017
I think it makes sense to just ignore
NaNinstead of throwing an error.pkozlowski-opensource commentedon Jan 26, 2017
Yeh, this wouldn't hurt. PR?
D-Thrane commentedon Jan 26, 2017
Thanks. I'm new to Angular. How do I fix this to wait until data i ready?
DzmitryShylovich commentedon Jan 26, 2017
http://plnkr.co/edit/30STyW3UJM7rqBQOhrzx?p=preview
D-Thrane commentedon Jan 26, 2017
Why is 360000 Milliseconds shown as 01:06:00. It's only 6 minutes?
DzmitryShylovich commentedon Jan 26, 2017
Try
new Date(360000)in a browser consoleD-Thrane commentedon Jan 26, 2017
It also looks like it remembers the first date pipe result and add this value to the next.
http://plnkr.co/edit/46PdAjWsH5bk4KFIsvpV?p=preview
D-Thrane commentedon Jan 26, 2017
new Date(360000) in console gives me "Thu Jan 26 2017 20:21:31 GMT+0100 (CET)"
fix(common): DatePipe doesn't throw for NaN (#14117)
D-Thrane commentedon Feb 11, 2017
So was there a date problem or?
http://plnkr.co/edit/46PdAjWsH5bk4KFIsvpV?p=preview
fix(common): DatePipe doesn't throw for NaN (angular#14117)
angular-automatic-lock-bot commentedon Sep 10, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.