How to display Yes/No instead of True/False in AngularJS [closed]

对着背影说爱祢 提交于 2019-12-01 11:29:53
mainguy

Create a simple filter like:

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

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

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

Here is a Plunker

You can add ng-options in your tag

ng-options="myMethod(item) for item in [true, false]"

Then define

$scope.myMethod = function(arg) {return arg ? 'Yes' : 'No'};

Hi Please see here: http://jsbin.com/bogir/1/edit?html,js

  <span ng-show="model">true</span>
  <span ng-hide="model">false</span>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!