如何处理包含使用角转换HTML字符串? [英] How to handle strings containing HTML using Angular-Translate?

查看:145
本文介绍了如何处理包含使用角转换HTML字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法告诉角度和角转换来处理,其中包含HTML内容字符串。

Is there a way to tell angular and angular-translate to handle strings which contains HTML content.

add_card标题=为了使订货更简单些,<跨度类=NOWRAP>接着&LT添加卡; / SPAN>中我的郎字符串。当我写使用它在我的模板< P> {{'add_card标题|翻译}}< / P> 我得到的字符串,因为它是

I have add_card-title = "To make ordering even quicker, <span class="nowrap">add a card now</span>" as my Lang string. When i use it in my template by writing <p>{{'add_card-title' | translate}}</p> I get string as it is.

输出: 为了使订货更简单些,&LT;跨度类=NOWRAP&gt;接着&LT添加卡; / SPAN&GT;
期望的输出: 为了更快的订货,现在添加一个卡

我知道我可以使用 NG-HTML绑定不安全,但它并没有帮助。

I know i can use ng-html-bind-unsafe but it is not helping.

不工作:

<p ng-html-bind-unsafe="{{'add_card-title' | translate}}"></p>

有没有办法实现呢?

Is there any way to achieve it?

下面是我的plunker:<一href=\"http://plnkr.co/edit/nTmMFm9B94BmbTgo2h8H?p=$p$pview\">http://plnkr.co/edit/nTmMFm9B94BmbTgo2h8H?p=$p$pview

Here is my plunker: http://plnkr.co/edit/nTmMFm9B94BmbTgo2h8H?p=preview

有关引用你可以看到这个问题:<一href=\"https://github.com/Pascal$p$pcht/angular-translate/issues/173\">https://github.com/Pascal$p$pcht/angular-translate/issues/173

For reference you can see this issue: https://github.com/PascalPrecht/angular-translate/issues/173

注意:我不想invlove控制器来处理它。

note: i do not want to invlove controller to handle it.

推荐答案

您可以做到这一点开箱的<一个href=\"http://angular-translate.github.io/docs/#/guide/05_using-translate-directive\">angular-translate 2.0 这些天。

You can do this out of box with angular-translate 2.0 these days.

<p translate="{{ 'PASSED_AS_INTERPOLATION' }}"></p> 

工程奇迹适合我。

works wonders for me.

这篇关于如何处理包含使用角转换HTML字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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