Using Angular 4.3.0
Say I have a string like this that is a property of a component.
<p>test#2 bla bla</p><p>test1234 56</p><p>test test</p>
So, Im following along with the docs,
https://angular.io/guide/template-syntax#!#property-binding-or-interpolation-
This does not work:
What am I doing wrong?
<div class="panel-group">
<div class="panel panel-default" *ngFor="let b of BlogPostList">
<div class="panel-heading">{{b.Title}}</div>
<div class="panel-body">
<span style="text-align:left">Created:{{b.DateCreated | date: 'MM/dd/yyyy'}}</span><span style="text-align:right">Last updated{{b.DateUpdated | date: 'MM/dd/yyyy'}}</span>
<br/>
<div [innerHTML]="<b>test here</b>"></div>
</div>
</div>
</div>
error:
Unhandled Promise rejection: Template parse errors:
Parser Error: Unexpected token < at column 1 in [<b>test here</b>] in ...</span>
<br/>
<div [ERROR ->][innerHTML]="<b>test here</b>"></div>
</div>
</div>
You need to pass your [innerHTML]
as a string wrap it with single quotes,
<div [innerHTML]="'<b>test here</b>'"></div>
You shoud write the parameter as a string.
<div [innerHTML]="'test here'"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With