angular-bootstrap-datepicker demo
https://github.com/cletourneau/angular-bootstrap-datepicker
HTML
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/2.0.4/css/bootstrap.min.css">
<link rel="stylesheet" href="https://rawgithub.com/cletourneau/angular-bootstrap-datepicker/master/dist/angular-bootstrap-datepicker.css">
<div>
<div data-ng-controller="AppCtrl">
<input id="datepicker" type="text" data-ng-datepicker data-ng-options="datepickerOptions" data-ng-model="date">
<input id="datepicker1" type="text" data-ng-datepicker data-ng-options="datepickerOptions" data-ng-model="date1">
<br>
<button data-ng-click="ukFormat()">UK Format</button>
<button data-ng-click="usFormat()">US Format</button>
<hr>
"Selected format: "{{format}} {{datepickerOptions.format}}
</div>
</div>
<script src="http://code.jquery.com/jquery-2.0.2.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/2.0.4/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script src="https://rawgithub.com/cletourneau/angular-bootstrap-datepicker/master/dist/angular-bootstrap-datepicker.js" charset="utf-8"></script>
JavaScript
app = angular.module('demo', ['ng-bootstrap-datepicker']);
app.controller('AppCtrl', function($scope) {
$scope.datepickerOptions = {
format: 'mm/dd/yy',
language: 'en',
autoclose: true
}
$scope.format= "US";
$scope.ukFormat = function (){
$scope.datepickerOptions = {
format: 'dd/mm/yy',
}
$scope.format = 'UK';
$scope.$broadcast('refreshDatepickers');
}
$scope.usFormat = function (){
$scope.datepickerOptions = {
format: 'mm/dd/yy',
}
$scope.format = 'US';
$scope.$broadcast('refreshDatepickers');
}
})
angular.module('ui.bootstrap.datepicker')
.config(function($provide) {
$provide.decorator('datepickerDirective', function($delegate) {
var directive = $delegate[0];
var link = directive.link;
directive.compile = function() {
return function(scope, element, attrs, ctrls) {
link.apply(this, arguments);
var datepickerCtrl = ctrls[0];
var ngModelCtrl = ctrls[1];
if (ngModelCtrl) {
// Listen for 'refreshDatepickers' event...
scope.$on('refreshDatepickers', function refreshView() {
datepickerCtrl.refreshView();
});
}
}
};
return $delegate;
});
});