这是我的控制器文件
$scope.htmlCompanyFromScope = '<span style=color:red>Micro</span>';
$scope.htmlTagFromScope = "MicroTag";
我的 *.resx文件包含
TranslationValue = "{{htmlCompany}} tag is {{htmlTag}}"
,在我的HTML
中,我定义了以下内容:
<span translate="TranslationValue " translate-values="{htmlCompany: htmlCompanyFromScope , htmlTag: htmlTagFromScope}"></span>
但最终,风格并没有得到尊重。显示
之类的东西微标签是Microtag
任何指针?
我假设您正在使用sanitize
策略来逃脱:
$translateProvider.useSanitizeValueStrategy('sanitize');
它使用$sanitize
服务,因此样式属性将被此服务剥离(为了覆盖此服务,您需要更改angular-sanitize.js
的源代码,但我不建议这样做)。作为在这里的解决方法 - 您需要使用class
属性(因为类属性未用$sanitize
剥离),例如class="red"
,并设置.red { color:red; }
等适当的CSS样式。
示例此处。
使用
<span style="color:red">
不是
<span style=color:red>