Angular标记在浏览器中提供HTML输出 [英] Angular tag giving HTML output in browser

查看:82
本文介绍了Angular标记在浏览器中提供HTML输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 {{testimonial.TestimonialText}}< small class =by-line>< i> {{testimonial.CoupleName}}< / i> 
< br />
< span class =location> {{testimonial.CoupleLocation}}< / span>
< / small>





我尝试过:
$ b $ {{testimonial.TestimonialText}}的
给出了带有html标签的文本输出我希望html在浏览器中被解释,但是他们正在浏览器中显示我试图解释与jquery但没有这样做,我试图使用@ HTML.Raw,但这是剃刀语法,不能在角标签上使用我是角度新手,不知道如何解决这个问题。

解决方案

如果testimonial.TestimonialText中的内容是HTML文本。请使用


sce初始化testimonial.TestimonialText。这是一个示例语法 -



 .controller(SampleCtrl,function(


sce){

{{ testimonial.TestimonialText }}<small class="by-line"><i>{{ testimonial.CoupleName }}</i>
<br/>
    <span class="location">{{ testimonial.CoupleLocation }}</span>
</small>



What I have tried:

for {{ testimonial.TestimonialText}} gives text output with html tags in it i want the html to be interpreted in browser but they
are being shown in browser i have tried to interpret with jquery but failed to do so and i tried to use @HTML.Raw but that is razor syntax which can't be used on angular tag i am new to angular and don't know how to get around this.

解决方案

If the content present in testimonial.TestimonialText is HTML text. Please initialize the testimonial.TestimonialText using


sce. Here's a sample syntax -

.controller( SampleCtrl , function(


sce){


这篇关于Angular标记在浏览器中提供HTML输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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