前端之家收集整理的这篇文章主要介绍了
angular ui-grid之过滤器设置,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
var app = angular.module('app',['ui.grid','ui.grid.edit']);
app.controller('MainCtrl',['$scope','$http',function ($scope,$http) {
$scope.gridOptions = {
columnDefs: [
{ field: 'name' },{ field: 'amount',name: 'Number',cellFilter: 'fractionFilter' },name: 'Currency',cellFilter: 'currencyFilter:this' }
]
};
$http.get('data.json')
.success(function (data) {
$scope.gridOptions.data = data;
});
}])
.filter('fractionFilter',function () {
return function (value) {
return value.toFixed(0);
};
})
.filter('currencyFilter',function () {
var currencyMap = {
'dollar': '$','pound': '£','euro': '€'
};
return function (value,scope) {
return currencyMap[scope.row.entity.currency] + value.toFixed(2);
};
})
;
原文链接:https://www.f2er.com/angularjs/147532.html