【问题标题】:AngularJS: translate and multiple ng-bind-html valuesAngularJS:翻译和多个 ng-bind-html 值
【发布时间】:2015-11-17 19:36:42
【问题描述】:

在我的应用程序中,我尝试连接两个字符串:电子邮件和一些文本。

但我有一个麻烦,我需要可翻译的文本部分“即时”所以我写道:

$scope.textUnsubscribe = 'SUCESSFULL_UNSUBSCRIBE';

在视图中:

<h4 ng-bind-html="textUnsubscribe | translate"></h4>

当然可以(电子邮件+文本):

<h4 ng-bind-html="userEmail"></h4>
<h4 ng-bind-html="textUnsubscribe | translate"></h4>

但是我有样式错误...

我可以以某种方式将两个范围变量放入一个ng-bind-html 吗?一个是“静态的”,第二个是可翻译的?

喜欢:

<h4 ng-bind-html="userEmail, (textUnsubscribe | translate)"></h4>

【问题讨论】:

  • @Pierre-AlexandreMoller 忘记 css ......连接两个变量是真的吗?

标签: javascript angularjs translate


【解决方案1】:

如果它只是像电子邮件这样的简单字符串。你不需要ng-bind-htmlng-bind 就足够了。添加-html 使ng-bind 更不安全。无论如何ng-bind 可以多次使用。如果您有“样式错误”,它来自您的 HTML(您有多个 h4)。

无论如何,你可以像这样在一个简单的ng-bind 上做到这一点:

<h4 ng-bind="userEmail +' '+ (textUnsubscribe | translate)"></h4>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-12
    • 2014-03-31
    • 2013-09-26
    • 2015-12-27
    相关资源
    最近更新 更多