<!DOCTYPE html>
<html ng-app="Demo" style="height:100%;">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Angular Moment Picker</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link href="//rawgit.com/indrimuska/angular-moment-picker/master/dist/angular-moment-picker.css" rel="stylesheet">
</head>
<body ng-cloak style="padding:20px;"
ng-controller="DemoController as ctrl">
<form name="myForm">
<div class="form-group">
<b>Range:</b>
from <code>{{ctrl.minDate.format('YYYY-MM-DD')}}</code>
to <code>{{ctrl.maxDate.format('YYYY-MM-DD')}}</code>
</div>
<div class="form-group"
ng-class="{
'has-success': myForm.myDate.$valid,
'has-error': myForm.myDate.$invalid
}">
<input class="form-control"
moment-picker="ctrl.stringDate"
locale="en"
format="YYYY-MM-DD"
validate="false"
start-view="month"
min-date="ctrl.minDate"
max-date="ctrl.maxDate"
name="myDate"
required="true"
placeholder="Select a date..."
ng-model="ctrl.momentDate"
ng-model-options="{ updateOn: 'blur' }">
</div>
<div class="form-group">
<button class="btn btn-info"
ng-click="ctrl.momentDate = ctrl.invalidMinDate">
Set date to <code>{{ctrl.invalidMinDate.format('YYYY-MM-DD')}}</code>
</button>
<button class="btn btn-info"
ng-click="ctrl.momentDate = ctrl.invalidMaxDate">
Set date to <code>{{ctrl.invalidMaxDate.format('YYYY-MM-DD')}}</code>
</button>
<button class="btn btn-info"
ng-click="ctrl.momentDate = undefined">
Reset date
</button>
</div>
<pre>{{ myForm.myDate.$error | json }}</pre>
<pre>{{ myForm.myDate | json }}</pre>
</form>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment-with-locales.js"></script>
<script src="//rawgit.com/indrimuska/angular-moment-picker/master/dist/angular-moment-picker.js"></script>
<script src="script.js"></script>
</body>
</html>
angular
.module('Demo', ['moment-picker'])
.controller('DemoController', ['$scope', function () {
var ctrl = this;
// init
ctrl.minDate = moment().subtract(1, 'day');
ctrl.maxDate = moment().add(1, 'day');
// invalid dates
ctrl.invalidMinDate = moment().subtract(5, 'day');
ctrl.invalidMaxDate = moment().add(5, 'day');
// methods
ctrl.setMinDate = function () { ctrl.momentDate = ctrl.invalidMinDate; };
ctrl.setMaxDate = function () { ctrl.momentDate = ctrl.invalidMaxDate; };
}]);
# Angular Moment Picker
Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
### More info at:
https://github.com/indrimuska/angular-moment-picker