sharpmachine
sharpmachine

Reputation: 3893

Using date pipe in a conditional expression - Angular 2

With the follow expression I'm expecting for Angular to interpolate a date (if not null) through the date pipe, but I get the proceeding 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

Is what I'm expecting possible, or just a...pipe dream :)

Upvotes: 46

Views: 28002

Answers (2)

amirnader afshari
amirnader afshari

Reputation: 11

For more than one pipe u can use

text="{{ item.COURSE_REGED == 0 ?  ('EDU_COURSE_SIGNUP'| translate ) +(item.COURSE_COST | number)+ ('PUP_CURRENCY_NAME' | translate)   : ('EDU_COURSE_SIGNED_UP'| translate) }}"

Upvotes: 1

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657248

Just wrap it with ()

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

Upvotes: 110

Related Questions