angular ui-grid之过滤器设置

来源:互联网 发布:unity3d塔防游戏 编辑:程序博客网 时间:2024/06/10 23:53
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' },      { field: 'amount', 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);  };});

2 0
原创粉丝点击