日期过滤器在AngularJS中不起作用..?

时间:2016-10-05 06:57:44

标签: angularjs

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

它给我的格式化输出不是

  

2016年10月10日星期一00:00:00

1 个答案:

答案 0 :(得分:1)

确保你的" $ scope.startDate"是一个约会对象。

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');
}]);

希望这有帮助。

仅供参考:创建了jsfiddle,here