如何使用 AngularJS 模板渲染 html [英] How to render html with AngularJS templates

查看:76
本文介绍了如何使用 AngularJS 模板渲染 html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的模板:

<ng:view></ng:view>

这是我的视图模板:

{{stuff.title}}

{{东西.内容}}

我将 content 作为 html 获取,我想在视图中显示它,但我得到的只是原始 html 代码.如何呈现该 HTML?

解决方案

使用-

你需要告诉 angular 不要逃避它.

This is my template:

<div class="span12">
  <ng:view></ng:view>
</div>

and this is my view template:

<h1>{{stuff.title}}</h1>

{{stuff.content}}

I am getting the content as html and I want to display that in a view, but all I am getting is raw html code. How can I render that HTML?

解决方案

Use-

<span ng-bind-html="myContent"></span>

You need to tell angular to not escape it.

这篇关于如何使用 AngularJS 模板渲染 html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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