详解angular ui-grid之过滤器设置
时间:2020-12-10 09:19:25|栏目:AngularJS|点击: 次
之前关于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' }, { 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); }; })
上一篇:详解angularJs模块ui-router之状态嵌套和视图嵌套
栏 目:AngularJS
下一篇:Angular.js中$resource高大上的数据交互详解
本文地址:http://www.codeinn.net/misctech/31428.html