这是我的过滤器的角度,我只展示了它的片段,应用程序。这在一个控制器中有效,但当我试图在另一个控制器中使用它时,它就没有了。
我的意思是它不起作用-它不会在DOM中呈现。不过,它会在标签内呈现。
AngularJS:<h2 ng-bind-html="'{{ answer.title }}' | to_trusted"></h2>
呈现<h2 ng-bind-html="'0-60 minutes per week' | to_trusted" class="ng-binding"></h2>的示例
AngularJS滤波器
.filter('to_trusted', ['$sce', function($sce){
return function(text) {
return $sce.trustAsHtml(text);
};
}])我是不是在这里偶然漏掉了什么东西?
发布于 2014-12-08 14:43:06
我认为使其工作的是这种语法,因为answer.title已经是文本了:
<h2 ng-bind-html="answer.title | to_trusted"></h2>https://stackoverflow.com/questions/27360406
复制相似问题