首先,我有一个过滤器“fromMSDate”,用于转换 json 日期而不是正常日期,如果放置此过滤器,则刷新绑定到 filterOptions.filterText 的输入,我得到“循环依赖”和“未知提供者:fromMSDate | dateFilterProvider <- fromMSDate '
//模块
var mainApp = angular.module('mainApp', ['ngGrid']);
//控制器
mainApp.controller('MandateListController', function MandateListController($scope) { $scope.filterOptions = { filterText: '' }; $scope.mandates = 数据; $scope.gridOptions = { 数据:“授权”, filterOptions: $scope.filterOptions, sortInfo:{字段:['ExpectedDate','ProjectName'],方向:['desc','asc'],列:['ExpectedDate','ProjectName']}, 列定义:[ { field: 'ProjectName', displayName: 'Project Name', width: '30%', cellClass: 'text-center' }, { field: 'Amount', displayName: 'Size', cellFilter: 'number:2', cellClass: 'text-right' }, { 字段:'RatingId',displayName:'Rating',cellClass:'text-center'}, { 字段:'CurrencyId',displayName:'Currency',cellClass:'text-center'}, { 字段:'MaturityId',displayName:'Maturity',cellClass:'text-center'}, { field: 'EstimatedPl', displayName: 'Estimated P/L', cellFilter: 'number:2', cellClass: 'text-right' }, { 字段:'ExpectedDate',displayName:'Expected Date',cellClass:'text-center',cellFilter:“fromMSDate | date:'mediumDate'”} ] }; });
//筛选
mainApp.filter("fromMSDate", [function () { var 结果 = 函数(日期,格式字符串){ 如果(格式字符串 === 空 || 格式字符串 === 未定义){ 格式字符串 = "DD MMM YYYY"; } 返回时刻(日期)。格式(格式字符串); }; 返回结果; }]);