设置在与MD-日期选择器
问题描述:
我现在用的MD-日期选择指令从角的材料,但是我想在日期TYP,不仅从日期选择器选择它MEANjs另一个日期备考。我发现下面的示例代码:设置在与MD-日期选择器
angular.module('MyApp')
.controller('AppCtrl', function($scope) {
$scope.myDate = new Date();
$scope.minDate = new Date(
$scope.myDate.getFullYear()-1,
$scope.myDate.getMonth(),
$scope.myDate.getDate());
$scope.maxDate = new Date(
$scope.myDate.getFullYear()+1,
$scope.myDate.getMonth(),
$scope.myDate.getDate()); })
.config(function($mdDateLocaleProvider) {
$mdDateLocaleProvider.formatDate = function(date) {
return date ? moment(date).format('DD.MM.YYYY') : '';
};
$mdDateLocaleProvider.parseDate = function(dateString) {
var m = moment(dateString, 'DD.MM.YYYY', true);
return m.isValid() ? m.toDate() : new Date(NaN);
};
});
我现在的问题是在哪里使用的.config部分在MEANJS自耕农发电机的应用。我找不到任何东西。有人这样做了吗?
答
如果您无法加载MD-日期选择文件并把它装载到MEAN.JS退房this answer。
然而,如果你已经正确地加载你的文件到您的应用程序,你只是要访问的应用程序的配置块,你可以通过访问位于/modules/core/client/app/init.js
文件这样做,并且在这个代码块只需添加所需的逻辑:
// Setting HTML5 Location Mode
angular
.module(app.applicationModuleName)
.config(bootstrapConfig);
function bootstrapConfig($compileProvider, $locationProvider, $httpProvider, $mdDateLocaleProvider) {
$locationProvider.html5Mode(true).hashPrefix('!');
$httpProvider.interceptors.push('authInterceptor');
// Disable debug data for production environment
// @link https://docs.angularjs.org/guide/production
$compileProvider.debugInfoEnabled(app.applicationEnvironment !== 'production');
// md-datepicker configuration
$mdDateLocaleProvider.formatDate = function(date) {
return date ? moment(date).format('DD.MM.YYYY') : '';
};
$mdDateLocaleProvider.parseDate = function(dateString) {
var m = moment(dateString, 'DD.MM.YYYY', true);
return m.isValid() ? m.toDate() : new Date(NaN);
};
}
bootstrapConfig.$inject = ['$compileProvider', '$locationProvider', '$httpProvider', '$mdDateLocaleProvider'];
不要忘记在配置块中注入$mdDateLocaleProvider
。
到目前为止,我把它在我的控制器等,并安装了片刻,注入但不知何故,它不能被发现。 – d8ta