Last active
December 13, 2016 18:49
-
-
Save hasibomi/b172caadf6af39f5a1cbd2ff0e3a2eb9 to your computer and use it in GitHub Desktop.
Angular directive for Zurb Foundation Datepicker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exaple:
<foundation-datepicker model="vm.fields.date" name="date" id="date"></foundation-datepicker>