如何使用AngularJS在文本中显示html标签[关闭](How to use AngularJS to show the html tag in the text [closed])

编程入门 行业动态 更新时间:2024-10-08 08:33:02
如何使用AngularJS在文本中显示html标签[关闭](How to use AngularJS to show the html tag in the text [closed])

我想在html中显示一些数据,数据如下: <p>abcd efg hijk....(<a href=\"http:\/\/www.facebook.com\/stock\/NBR\">NYSE:NBR<\/a>),如你所见,有一些html标签,但是当我使用angularJS来显示这些数据时,浏览器无法将这些数据识别为html标签。

有人知道怎么做吗?

I want to show some data in the html, the data like this: <p>abcd efg hijk....(<a href=\"http:\/\/www.facebook.com\/stock\/NBR\">NYSE:NBR<\/a>),,as you see,there are some html tags, but when I use the angularJS to show these data, the Browser cannot recognize these data as html tag.

Anybody know how to do this?

最满意答案

您可以使用ngBindHtml

<ANY ng-bind-html="expression"> ... </ANY>

假设你对$ scope.htmtText = ....有价值

<div ng-bind-html="htmtText"></div>

请参阅文档

You can use ngBindHtml

<ANY ng-bind-html="expression"> ... </ANY>

Say you have value on $scope.htmtText = .... then

<div ng-bind-html="htmtText"></div>

See the documentation

更多推荐

本文发布于:2023-08-07 12:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464144.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   标签   文本中   AngularJS   closed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!