npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

angular-flatpickr

v3.6.6

Published

angular directive for flatpickr

Downloads

1,409

Readme

Build Status

Angular-flatpickr

An angular directive to use flatpickr. Currently it has following capabilities

  • setting init options using fp-opts attribute
  • on setup callback using fp-on-setup attribute to get the created flatpickr object

There are now support for a directive based approach and a component based

Install

  • install it with npm install -S angular-flatpickr
  • Add the dependency
    • Component based angular 1.5+ - node_modules/angular-flatpickr/dist/ng-flatpickr-comp.js
    • Directive based angular older - node_modules/angular-flatpickr/dist/ng-flatpickr.js
  • Add the angular-flatpickr module in your app as shown
var module = angular.module('atApp.somemodule', [
  'angular-flatpickr' // <- important
]);

Example as Component

  • inside your parent controller or component set your default options and the post setup callback
ctrl.dateOpts = {
  dateFormat: 'Y-m-d',
  placeholder: 'Change date..', // Default: 'Select Date..'
  defaultDate: '2016-03-01 03:30:00 -0300',
  onChange: function(selectedDates, dateStr, instance) {
    // Do stuff on change
  }
};

ctrl.datePostSetup = function(fpItem) {
  console.log('flatpickr', fpItem);
}
2 ways to use the component, first is just stating the ng-flatpickr
<ng-flatpickr
  fp-opts="$ctrl.dateOpts"
  fp-on-setup="$ctrl.datePostSetup({
    fpItem: fpItem
  })">
</ng-flatpickr>
The other way is if you want to set a placeholder or do something in the inside element you can use it like this
<ng-flatpickr
  fp-opts="$ctrl.dateOpts"
  fp-on-setup="$ctrl.datePostSetup({
    fpItem: fpItem
  })">
</ng-flatpickr>
If ng-model is stated it will set the initial date to match it
<ng-flatpickr
  ng-model="'28-10-2018'"
  fp-opts="$ctrl.dateOpts"
  fp-on-setup="$ctrl.datePostSetup({
    fpItem: fpItem
  })">
</ng-flatpickr>

Example as Directive

  • inside your controller set your default options and the post setup callback
$scope.dateOpts = {
  dateFormat: 'Y-m-d',
  placeholder: 'Change date..', // Default: 'Select Date..'
  defaultDate: '2016-03-01 03:30:00 -0300',
  onChange: function(selectedDates, dateStr, instance){
    // Do stuff on change
  }
};

$scope.datePostSetup = function(fpItem) {
  console.log('flatpickr', fpItem);
}
<div ng-repeat="date in dates">
  <input
    ng-flatpickr
    fp-opts="dateOpts"
    fp-on-setup="datePostSetup(fpItem)"
    ng-model="date.selectedDateObj"
    data-enabletime="true">
</div>

Note: This directive doesn't watch over the fp-opts values. For doing any changes to the flatpickr element created, use object returned from the on-setup callback

License

angular-flatpickr module is under MIT license see project root