Reputation: 895
Is it possible to use pipes in HTML tags?
<h1 [innerHTML]="date ? date | date : '<i>Date not set</i>'"></h1>
If date
is defined the date with the date-pipe should be display. Otherwise Date not set
should be displayed.
The code above doesn't work.
What is the best way to achieve this?
EDIT
Thanks to @Pankaj Parkar
The solution is
<h1 [innerHTML]="date ? (date | date) : '<i>Date not set</i>'"></h1>
I tried with {{ }}
and [[ ]]
but only ( )
works.
Upvotes: 1
Views: 6843
Reputation: 16917
Pankaj Parkar
is right!
Use it like this:
<h1 [innerHTML]="date ? (date | date) : '<i>Date not set</i>'"></h1>
Upvotes: 3