Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A bootstrap-datepicker angular directive
(function($) {
var app = angular.module("siDate", [])
.directive('datePicker', [datePicker]);
function datePicker() {
return {
restrict: 'EA', //E = element, A = attribute, C = class, M = comment
replace: true,
scope: {
//@ reads the attribute value, = provides two-way binding, & works with functions
name: '@',
placeholder: '@',
date: '=?'
},
template: '<input class="datepicker form-control" ' +
' name="{{ name }}" ng-model="date" ' +
' placeholder="{{ placeholder }}" ' +
' required/>',
link: function($scope, element, attrs) {
} //DOM manipulation
};
}
})(window.jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.