这是一个骗子:
http://plnkr.co/edit/b9NSk0
尝试在任何日期开始输入2014年。
Bug还是我错过了什么?
// main.js
var app = angular.module('myApp', ['ui.grid', 'ui.grid.i18n']);
app.controller('MyCtrl', function($scope) {
$scope.myData = [{
eventName: "event1",
eventDateRaw: new Date(1416396274368),
eventDateFormatted: new Date(1416396274368)
}, {
eventName: "event2",
eventDateRaw: new Date(1416352423803),
eventDateFormatted: new Date(1416396274368)
}];
$scope.gridOptions = {
data: 'myData',
columnDefs: [{
name: 'eventName', width: "20%"
}, {
name: 'eventDateRaw', width: "40%"
}, {
name: 'eventDateFormatted', width: "40%",
cellFilter: 'date: "yyyy-MM-dd HH:mm:ss.sss"'
}],
enableFiltering: true
};
});
BR remy44
答案 0 :(得分:2)
尝试添加类型:
{
name: 'eventDateFormatted', width: "40%",
cellFilter: 'date: "yyyy-MM-dd HH:mm:ss.sss"',
type: 'date'
}
答案 1 :(得分:0)
尝试反转引号,以便使用单引号传入参数。
javascript
cellFilter: "date: 'yyyy-MM-dd HH:mm:ss.sss'"
答案 2 :(得分:0)
cellTemplate:' {{row.entity.delivery_month |日期:" yyyy MMM"}}',
答案 3 :(得分:0)
我不知道它为什么不在声明阶段工作但这应该有效:
// main.js
var app = angular.module('myApp', ['ui.grid', 'ui.grid.i18n']);
app.controller('MyCtrl', function($scope) {
$scope.myData = [{
eventName: "event1",
eventDateRaw: new Date(1416396274368),
eventDateFormatted: new Date(1416396274368)
}, {
eventName: "event2",
eventDateRaw: new Date(1416352423803),
eventDateFormatted: new Date(1416396274368)
}];
$scope.gridOptions = {
data: 'myData',
columnDefs: [{
name: 'eventName', width: "20%"
}, {
name: 'eventDateRaw', width: "40%"
}, {
name: 'eventDateFormatted', width: "40%"
}],
enableFiltering: true
};
$scope.gridOptions.columnDefs[2].cellFilter = "date:'dd/MM/yyyy'";
});
注意最后一行