這在jsfiddle更新之前工作,現在它不起作用。任何幫助將受到歡迎。我與時刻和角度過濾器的問題
下面是HTML
<div ng-app="app" ng-controller="ctrl">
{{ date | date: 'MM-dd-yy' }} <br/> <br/>
{{ date | date: 'MMM-dd-yyyy' }} <br/> <br/>
{{ date | date: 'MMMM-dd-yyyy' }} <br/> <br/>
{{ d | date: 'MM/dd/yy' }} <br/> <br/>
{{ d | date: 'MMM/dd/yyyy' }}
</div>
...這裏是JavaScript
var app = angular.module("app", []);
app.constant("moment", moment);
app.controller("ctrl", function($scope, moment) {
$scope.d = new Date();
$scope.date = new moment();
$scope.getRandomDate = function(){
var year = Math.floor(Math.random() * 2) + 2014;
var month = Math.floor(Math.random() * 12) ;
var day = Math.floor(Math.random() * 31);
return moment([year, month, day]).toDate();
};
$scope.date = $scope.getRandomDate();
});
https://jsfiddle.net/galnova/tkchx8me/8/
非常感謝! – riotgear