I am writing an Angular application and I have an HTML response I want to display.
How do I do that? If I simply use the binding syntax {{myVal}}
it en
On angular2@2.0.0-alpha.44:
Html-Binding will not work when using an {{interpolation}}
, use an "Expression" instead:
invalid
-> throws an error (Interpolation instead of expected Expression)
correct
-> this is the correct way.
you may add additional elements to the expression, like:
'+item.anleser+''">
hint
HTML added using [innerHTML]
(or added dynamically by other means like element.appenChild()
or similar) won't be processed by Angular in any way except sanitization for security purposed.
Such things work only when the HTML is added statically to a components template. If you need this, you can create a component at runtime like explained in How can I use/create dynamic template to compile dynamic Component with Angular 2.0?