角2 HTML结合 [英] angular 2 html binding

查看:331
本文介绍了角2 HTML结合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个角2应用程序,它是一个ASP.NET MVC应用程序的一部分。我希望能够利用Ajax加载的局部视图,并显示它。我有我的控制器设置了这一点,我可以让Ajax调用,并获得HTML响应。但是,我怎么显示呢?如果我只是使用绑定语法 {{}设为myVal} 它连接codeS所有的HTML字符(当然)。

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).

我需要以某种方式的div的内部HTML绑定到变量的值。

I need somehow to bind the inner html of a div to the variable value.

谢谢!

推荐答案

正确的语法现在是以下内容:

The correct syntax is now the following:

<div [innerHTML]="theHtmlString">
</div>

在工作
angular2:2.0.0-alpha.52

这篇关于角2 HTML结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆