Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use HTML tags in interpolation syntax

Tags:

angular

How can I use in interpolations HTML tags in HTML templates with Angular 2?

For example:

<h1> {{title ? title : '<i>Title not set</i>'}} </h1>

If the title is undefined then there should be a Title not set in i-Tags.

If I use the syntax above Angular will display exactly the expression (means with the {{, ?, :, }}) and does not evaluate it.

like image 745
Rose Nettoyeur Avatar asked Aug 09 '16 17:08

Rose Nettoyeur


1 Answers

<h1 [innerHTML]="title ? title : '<i>Title not set</i>'"></h1>

See also In RC.1 some styles can't be added using binding syntax

like image 98
Günter Zöchbauer Avatar answered Oct 31 '22 21:10

Günter Zöchbauer