在我的应用程序中,我尝试连接两个字符串:电子邮件和一些文本。
但我遇到麻烦,我需要文本部分可翻译“动态”所以我写道:
$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>
答案 0 :(得分:6)
如果它只是简单的字符串,如电子邮件。您不需要ng-bind-html
,ng-bind
就足够了。添加-html
会使ng-bind
更安全。无论如何ng-bind
可以多次使用。如果你有一个&#34;风格的错误&#34;有了它,它来自你的HTML(你有多个h4
)。
无论如何,你可以在一个简单的ng-bind
上这样做:
<h4 ng-bind="userEmail +' '+ (textUnsubscribe | translate)"></h4>