角2 html绑定 [英] angular 2 html binding
本文介绍了角2 html绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
{{myVal}}
,则会编码所有html字符(当然)。 我需要以某种方式将div的内部html绑定到变量值。
谢谢!
解决方案
正确的语法现在如下:
< div [innerHTML] =theHtmlString >
< / div>
工作在
2.4.0
I am writing an Angular 2 application which is part of an ASP.NET MVC application. I want to be able to use ajax to load a partial view and display it. I have my controller set up for this, and I can make the ajax call and get the html response. However, how do I display it? If I simply use the binding syntax {{myVal}}
it encodes all html characters (of course).
I need somehow to bind the inner html of a div to the variable value.
Thanks!
解决方案
The correct syntax is now the following:
<div [innerHTML]="theHtmlString">
</div>
Working in
"2.4.0"
这篇关于角2 html绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文