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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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
回答2:
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'};
回答3:
Hi Please see here: http://jsbin.com/bogir/1/edit?html,js
<span ng-show="model">true</span>
<span ng-hide="model">false</span>