Date Filter在AngularJS中不起作用..?

问题描述:

$scope.schemeInfo.schemeStartDate = $filter("date")($scope.startDate,"dd/MM/yyyy"); 

它给我未格式化输出Date Filter在AngularJS中不起作用..?

周一10月10日00:00:00 PDT 2016

+0

我认为,增加更多的代码将是有益的,尤其是控制器和视图。 – palra

+0

你记录了你的'$ scope.startDate'吗? – Zakaria

+0

你能告诉我们'$ scope.startDate'吗? – Weedoze

确保你的 “$ scope.startDate” 为Date对象。

var app = angular.module('MyApp', []); 

app.controller('MyCtrl', ['$scope', '$filter', function($scope, $filter) 
{ 
    $scope.myDate = new Date('Mon Oct 10 00:00:00 PDT 2016'); 
    $scope.myDateFiltered = $filter('date')($scope.myDate, 'dd/MM/yy'); 
}]); 

希望这会有所帮助。

FYI:创造了的jsfiddle,here