Skip to content

Instantly share code, notes, and snippets.

@hasibomi
Last active December 13, 2016 18:49
Show Gist options
  • Save hasibomi/b172caadf6af39f5a1cbd2ff0e3a2eb9 to your computer and use it in GitHub Desktop.
Save hasibomi/b172caadf6af39f5a1cbd2ff0e3a2eb9 to your computer and use it in GitHub Desktop.
Angular directive for Zurb Foundation Datepicker
/**
* Author: Hasibur Rahman Omi.
* Email: [email protected].
* Author URI: http://www.hasibomi.com.
*/
class FoundationDatepicker {
constructor() {
this.restrict = "E";
this.replace = true;
this.scope = {
format: "@",
disableDblClickSelection: "@",
language: "@",
pickTime: "@",
model: "=",
name: "@",
id: "@"
};
this.template = '<input type="text" name="{{ name }}" id="{{ id }}" ng-model="model">';
this.link = this.linkFunc;
}
/**
* Directive link function.
*
* @param scope
* @param elm
* @param attr
*/
linkFunc(scope, elm, attr) {
elm.fdatepicker({
format: attr.format || "mm-dd-yyyy",
disableDblClickSelection: attr.disableDblClickSelection || true,
language: attr.language || "vi",
pickTime: attr.pickTime || false
});
}
}
angular.module("angular-foundation-datepicker", []).directive("foundationDatepicker", () => new FoundationDatepicker);
@hasibomi
Copy link
Author

Exaple: <foundation-datepicker model="vm.fields.date" name="date" id="date"></foundation-datepicker>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment