Skip to content

Instantly share code, notes, and snippets.

@matthewbednarski
Created October 1, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewbednarski/bc40eed5614920e194a5 to your computer and use it in GitHub Desktop.
Save matthewbednarski/bc40eed5614920e194a5 to your computer and use it in GitHub Desktop.
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
};
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment