Skip to content

Instantly share code, notes, and snippets.

@tuckbloor
Last active March 2, 2016 09:25
Show Gist options
  • Save tuckbloor/9908ab0f556381bfee2f to your computer and use it in GitHub Desktop.
Save tuckbloor/9908ab0f556381bfee2f to your computer and use it in GitHub Desktop.
angular datepicker instance for multiple datepickers
html
<p class="input-group">
<input type="text" class="form-control" datepicker-popup="{{format}}" ng-model="latestRevision(dValue).date_returned" close-text="Close" datepicker-options="datePicker.options" is-open="datePicker.instances['returned'+dValue.document_id]" />
<span class="input-group-btn">
<button type="button" class="btn btn-sm btn-default no-border" datepicker-options="datePicker.options" close-text="Close" ng-click="datePicker.open($event, 'returned'+dValue.document_id)"><i class="fa fa-calendar"></i></button>
</span>
</p>
js
$scope.datePicker = (function() {
var method = {};
method.instances = [];
method.open = function($event, instance) {
$event.preventDefault();
$event.stopPropagation();
method.instances[instance] = true;
};
method.options = {
'show-weeks': false,
startingDay: 0
};
method.format = 'dd/MM/yyyy';
return method;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment