首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AngularJS ng-bind

AngularJS ng-bind
EN

Stack Overflow用户
提问于 2014-12-08 14:40:00
回答 1查看 412关注 0票数 0

这是我的过滤器的角度,我只展示了它的片段,应用程序。这在一个控制器中有效,但当我试图在另一个控制器中使用它时,它就没有了。

我的意思是它不起作用-它不会在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滤波器

代码语言:javascript
复制
    .filter('to_trusted', ['$sce', function($sce){
        return function(text) {
            return $sce.trustAsHtml(text);
        };
    }])

我是不是在这里偶然漏掉了什么东西?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-08 14:43:06

我认为使其工作的是这种语法,因为answer.title已经是文本了:

代码语言:javascript
复制
<h2 ng-bind-html="answer.title | to_trusted"></h2>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27360406

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档