Angularjs 显示包含从筛选函数返回的HTML的输出
加价:Angularjs 显示包含从筛选函数返回的HTML的输出,angularjs,angular-filters,Angularjs,Angular Filters,加价: <div class="vpScoreInner" ng-bind-html="reason | truncate:limit:20:" ..."> 我认为您不需要在这里使用$sce,过滤器返回的值直接返回到ngBindHtml指令,该指令将为您清理和呈现HTML 如果查看$sce.trustAsHTML的AngularJS文档($sce),它将返回一个需要传递给$sce.getTrustedHTML Returns An object that can be passe
<div class="vpScoreInner" ng-bind-html="reason | truncate:limit:20:" ...">
我认为您不需要在这里使用$sce
,过滤器返回的值直接返回到ngBindHtml
指令,该指令将为您清理和呈现HTML
如果查看$sce.trustAsHTML
的AngularJS文档($sce),它将返回一个需要传递给$sce.getTrustedHTML
Returns
An object that can be passed to $sce.getTrustedHtml(value) to obtain
the original value. (privileged directives only accept expressions that
are either literal constants or are the return value of $sce.trustAs.)
我认为您只需要返回您创建的直接HTML字符串,然后让ngBindHTML
完成其余的工作
编辑:这里有一个简单的过滤器,它可以将字符串切碎成相同的大小,并插入一个双断点:您是否尝试过这里的答案:使用ng bind html是正确的,但也必须将ngSanitize添加到模块中。
Returns
An object that can be passed to $sce.getTrustedHtml(value) to obtain
the original value. (privileged directives only accept expressions that
are either literal constants or are the return value of $sce.trustAs.)