Angularjs directive for flatpickr.Pleas do the following to use ng-flatpicker
.
- just add
ng-flatpicker
to your input.Default dateformat isY-m-d
. - You can specify alot of options. To do that just add
options
attribute object in your element.
Before installation you must to include flatpickr to your project.
Install with npm
npm i ng-flatpickerr
After run the above command
- Include
ng-flatpicker.min.js
to your project. - And then add
ng-flatpicker
modules to your angularjs application.
Example
var myapp = angular.module("myapp", ["ng-flatpicker"]);
To use ng-flatpicker
you just need add ng-flatpicker
attribute and options
to your element.
<input
type="text"
ng-flatpicker
options="{dateFormat:'Y-m-d'}"
placeholder="Select a date"
ng-model="demoDate"
/>
Define options to your controller.
var myapp = angular.module("myapp", ["ng-flatpicker"]);
angular.module("myapp").controller("demoCtrl", function($scope) {
$scope.options = {
dateFormat: "Y-m-d",
enabledTime: true
};
});
and then to your view file
<input
type="text"
ng-flatpicker
options="options"
placeholder="Select a date"
ng-model="demoDate"
/>
Note: Need to deine ng-model
in your element.
ng-flatpicker
module is under MIT license see project root