如何显示是/否而不是在AngularJS真/假 [英] How to display Yes/No instead of True/False in AngularJS

查看:146
本文介绍了如何显示是/否而不是在AngularJS真/假的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在用的是cellTemplate显示在网格中的数据,现在我要显示在NG-电网,在那里我可以显示一列包含true或false值的数据资料,请指导我如何显示的真实还是假的数据,如Yes或No,即真正的价值,我必须显示是和假值没有。请指引我什么改变让我需要的结果。

I am using the cellTemplate to display the data in grid ,now i have to display the data in ng-grid ,where i can display the data containing true or false value in one column ,please guide me how to display the true or false data like yes or no ,i.e ,for true value i have to display yes and for false value to no .please guide me what changes in makes my required result.

推荐答案

创建一个简单的过滤器,如:

Create a simple filter like:

app.filter('true_false', function() {
    return function(text, length, end) {
        if (text) {
            return 'Yes';
        }
        return 'No';
    }
});

和在cellTemplate使用(或任何你想要的):

and use it in your cellTemplate (or wherever you want):

cellTemplate: '<div class="ngCellText">{{row.getProperty(col.field) | true_false}}</div>'

下面是一个 Plunker

这篇关于如何显示是/否而不是在AngularJS真/假的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆