【发布时间】:2017-06-24 22:26:56
【问题描述】:
角度材料的日期选择器。 我想将日期选择器的格式更改为 dd-mm-yyyy。
angular.module('MyApp')
.controller('AppCtrl', function($scope) {
$scope.myDate = new Date();
$scope.minDate = new Date(
$scope.myDate.getFullYear(),
$scope.myDate.getMonth() - 2,
$scope.myDate.getDate());
$scope.maxDate = new Date(
$scope.myDate.getFullYear(),
$scope.myDate.getMonth() + 2,
$scope.myDate.getDate()); }).config(function($mdDateLocaleProvider) {
$mdDateLocaleProvider.formatDate = function(date) {
return moment(date).format('YYYY-MM-DD');
};
});
但我希望对应用程序中的所有日期选择器进行一次配置。 我认为这个示例适用于单个日期选择器。
【问题讨论】:
-
是 uib-datepicker 吗?那么这应该有助于stackoverflow.com/questions/23343371/…
-
由 angular.module('app').config(function($mdDateLocaleProvider) { $mdDateLocaleProvider.formatDate = function(date) { return moment(date).format('YYYY-MM- DD'); }; });
标签: angularjs angularjs-material