I am trying to add html content in angular material but the tags show as simple text in html for example "first line <br>
.here should be a new line" How do I do it?
You can use innerHTML
attribute binding
<td mat-cell
*matCellDef="let element"
[innerHTML]="element.name">
</td>
TS
const ELEMENT_DATA: PeriodicElement[] = [
{
position: 1,
name: '<b>Hydrogen</b> <br>Test',
...
},
...
];
Output
Position | Name |
---|---|
1 | Test |
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.