Yes, I have been searching through the angular 2 docu and tried already all the different versions, but it didn´t work.
Strangely, now I even get an error with the [inner-html] that says:
Canât bind to âinner-htmlâ since it isnât a known native property.
This actually didn´t throw an error before. But I have upgraded to alpha48âŚmaybe that broke itâŚ
Hi,
yes, I have seen that article, too. But as far as I understand it, that is targetting a different use case. I believe he wants to be able to dynamically âexecuteâ html like
So the âmy-angular-componentâ gets expanded to whatever template is defined for it.
My use case is actually very simple: I want to display (read-only) simple text in a <div>{{myText}}</div> that I read from a database. This text has very basic html-tags mainly for line-break:
<div>this is line 1 <br />and here goes line two <br />and here is line 3</div>
That is all I needâŚit can´t be so difficult, can it?
meanwhile you can always take the string, split it into an array, compare itâs values and you can reconstruct the string-value html in a dynamic template containing your basic html markup. It is even easier if your html string is consistent in it`s markup.
Iâve done this in angular1, but not yet in angular2.
I had a quick look at the documentation and it seems still possible. When I have a bit of time, Iâll try and generate a codepen.
Hopefully they fix [inner-html] in a coming beta release.
The most solid answer is âfigure out another way to achieve your goalâ. This is deliberately unsupported in Angular 2+, for IMHO very good reasons. Here is one alternative approach.
SweeetâŚafter trying all the other options this one works.
In my example, binding the inner html to my component variable syntactically worked like this.
<span [innerHTML]=menuOption.title>