Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 显示包含从筛选函数返回的HTML的输出_Angularjs_Angular Filters - Fatal编程技术网

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.)