Using date in conditional expression - Angular 2

In the following expression, I expect for Angular to interpolate the date (if not null) through the date channel, but I get a continuation error.

{{charge.offenseDate ? charge.offenseDate | date : 'No date'}} EXCEPTION: Error: Uncaught (in promise): Template parse errors: Parser Error: Conditional expression {{charge.offenseDate ? charge.offenseDate | date : 'No Date' }} requires all 3 expressions at the end of the expression 

This is what I expect, or just ... a dream :)

+5
source share
1 answer

Just wrap it ()

 {{charge.offenseDate ? (charge.offenseDate | date) : 'No date'}} 
+19
source

All Articles