Code Monkey home page Code Monkey logo

ng2-flatpickr's Introduction

Build Status

ng2-flatpickr

ng2-flatpickr is a lightweight Angular wrapper for flatpickr, which is usable in reactive forms inside Angular.

Examples are here: https://mezoistvan.github.io/ng2-flatpickr-examples/.

npm install --save flatpickr ng2-flatpickr
yarn add flatpickr ng2-flatpickr

How to use:

Import the Ng2FlatpickrModule to your NgModule:

import { Ng2FlatpickrModule } from 'ng2-flatpickr';

@NgModule({
  imports: [
    Ng2FlatpickrModule
    ...

Example usage in a form component html template:

<ng2-flatpickr formControlName="formControlName"></ng2-flatpickr>

Overwrite the default flatpickr properties by inputting any of the flatpickr options: https://chmln.github.io/flatpickr/options/

import { FlatpickrOptions } from 'ng2-flatpickr';

let exampleOptions: FlatpickrOptions = {
  defaultDate: '2017-03-15'
};

<ng2-flatpickr [config]="exampleOptions" formControlName="formControlName"></ng2-flatpickr>

Add locale to the options

import { FlatpickrOptions } from 'ng2-flatpickr';
import Russian from 'flatpickr/dist/l10n/ru.js';

let exampleOptions: FlatpickrOptions = {
  locale: Russian.ru,
  ...
};

<ng2-flatpickr [config]="exampleOptions" formControlName="formControlName"></ng2-flatpickr>

Set a placeholder for the input:

<ng2-flatpickr placeholder="Pick a date!" formControlName="formControlName"></ng2-flatpickr>

Set a date using a string or a date object:

let randomDateString = '1988-09-19';
let randomDateObject = new Date( 1234567891011 );

<ng2-flatpickr [setDate]="randomDateString" formControlName="formControlName"></ng2-flatpickr>
<ng2-flatpickr [setDate]="randomDateObject" formControlName="formControlName"></ng2-flatpickr>

Flatpickr css needs to be loaded separately. when using @angular/cli, load it in angular.json.

"styles": [
  "node_modules/flatpickr/dist/flatpickr.min.css"
]

ng2-flatpickr's People

Contributors

abuzerasif avatar ahmed-anas avatar d42ohpaz avatar dockleryxk avatar linktohack avatar ly2xing avatar manar-mk avatar mezoistvan avatar msuntharesan avatar murazaki avatar rip3rs avatar robert3191 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ng2-flatpickr's Issues

Production builds

Hi,

I just moved to the production phase on a large project and I am getting this error when building my project with the "--prod"-switch on. Like this: "ng build --prod".

"ERROR in Unexpected value 'Ng2FlatpickrComponent in C:/Users/rj/Documents/Workspace/PROJECT_NAME/node_modules/ng2-flatpickr/src/ng2-flatpickr.component.d.ts' declared by the module 'AppModule in C:/Users/rj/Documents/Workspace/PROJECT_NAME/src/app/app.module.ts'. Please add a @Pipe/@Directive/@component annotation. ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'C:\Users\rj\Documents\Workspace\PROJECT_NAMEI\src' @ ./src/main.ts 3:0-74 @ multi ./src/main.ts"

There seems to be a problem with the ng2-flatpickr library and the build is not successful. Before I investigate further and/or create a plunkr, I just want to ask if anyone else are having similar problems?

These are my dependencies:


 "dependencies": {
    "@agm/core": "^1.0.0-beta.0",
    "@amcharts/amcharts3-angular": "^1.2.1",
    "@angular/animations": "^4.2.5",
    "@angular/common": "^4.2.5",
    "@angular/compiler": "^4.2.5",
    "@angular/core": "^4.3.3",
    "@angular/forms": "^4.2.5",
    "@angular/http": "^4.2.5",
    "@angular/platform-browser": "^4.2.5",
    "@angular/platform-browser-dynamic": "^4.2.5",
    "@angular/platform-server": "^4.2.5",
    "@angular/router": "^4.2.5",
    "@reactivex/rxjs": "^5.4.2",
    "@types/lodash": "^4.14.68",
    "angular-font-awesome": "^2.0.2",
    "angular2-google-maps": "^0.17.0",
    "angular2-qrscanner": "^0.1.7",
    "chart.js": "^2.5.0",
    "core-js": "^2.4.1",
    "d3": "^4.9.1",
    "font-awesome": "^4.7.0",
    "lodash": "^4.17.4",
    "ng2-flatpickr": "^0.1.18",
    "ng2-nvd3": "^2.0.0-rc3",
    "ng2-toastr": "^4.1.2",
    "ng2-translate": "^5.0.0",
    "rxjs": "^5.1.0",
    "sprintf-js": "^1.1.1",
    "ts-helpers": "^1.1.2",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@angular/cli": "^1.2.0",
    "@angular/compiler-cli": "^4.2.5",
    "@types/jasmine": "^2.5.53",
    "@types/node": "^8.0.7",
    "angular-2-local-storage": "^1.0.1",
    "angular2-template-loader": "^0.6.2",
    "codelyzer": "3.1.2",
    "electron": "^1.6.11",
    "jasmine-core": "^2.7.0",
    "jasmine-spec-reporter": "^4.1.1",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.3.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-remap-istanbul": "^0.6.0",
    "protractor": "^5.1.2",
    "reflect-metadata": "^0.1.10",
    "rxjs": "^5.4.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.5.0",
    "typescript": "~2.3.3",
    "wallaby-webpack": "0.0.38"
  }

Thanks!

TypeError: this.flatpickrElement.nativeElement.flatpickr is not a function in prod build

ERROR { TypeError: this.flatpickrElement.nativeElement.flatpickr is not a function at Ng2FlatpickrComponent.ngAfterViewInit (/usr/src/project/node_modules/ng2-flatpickr/bundles/~/ng2-flatpickr/src/ng2-flatpickr.component.ts:58:56) at callProviderLifecycles (/usr/src/project/node_modules/packages/core/esm5/src/view/provider.js:591:9) at callElementProvidersLifecycles (/usr/src/project/node_modules/packages/core/esm5/src/view/provider.js:558:12) at callLifecycleHooksChildrenFirst (/usr/src/project/node_modules/packages/core/esm5/src/view/provider.js:541:2) at checkAndUpdateView (/usr/src/project/node_modules/packages/core/esm5/src/view/view.js:400:5) at callViewAction (/usr/src/project/node_modules/packages/core/esm5/src/view/view.js:742:14) at execComponentViewsAction (/usr/src/project/node_modules/@angular/core/bundles/core.umd.js:14123:13) at checkAndUpdateView (/usr/src/project/node_modules/@angular/core/bundles/core.umd.js:13846:5) at callViewAction (/usr/src/project/node_modules/packages/core/esm5/src/view/view.js:742:14) at execComponentViewsAction (/usr/src/project/node_modules/@angular/core/bundles/core.umd.js:14123:13) at checkAndUpdateView (/usr/src/project/node_modules/@angular/core/bundles/core.umd.js:13846:5) at callViewAction (/usr/src/project/node_modules/packages/core/esm5/src/view/view.js:742:14) at execEmbeddedViewsAction (/usr/src/project/node_modules/@angular/core/bundles/core.umd.js:14149:17) at checkAndUpdateView (/usr/src/project/node_modules/packages/core/esm5/src/view/view.js:392:5) at callViewAction (/usr/src/project/node_modules/packages/core/esm5/src/view/view.js:742:14) at execComponentViewsAction (/usr/src/project/node_modules/@angular/core/bundles/core.umd.js:14123:13)

Open the calendar by clicking another html element

Is there a way to call the flatpickr calendar by clicking a button and insert the selected date into another input field? Something like:
image

I tried the code below but without success:

<div class="input-group">
     <span class="input-group-btn">
         <button type="button" class="btn btn-primary btn-icon" (click)="d.toggle()">
              <i class="ion-android-calendar"></i>
         </button>
     </span>
    <input class="form-control " placeholder="Data de Nascimento" name="nascimento"
         ng2-flatpickr  #d="ng2-flatpickr" formControlName="nascimento"
         (focus)="d.open()" (click)="d.open()">
</div>

angular aot build error

when i run "node_modules/.bin/ngc -p tsconfig-aot.json" ,it not work right ,it show info below

Unexpected value 'Ng2FlatpickrComponent in /Users/karas/projects/smart-raise/node_modules/ng2-flatpickr/src/ng2-flatpickr.component.d.ts' declared by the module 'HomeModule in /Users/karas/projects/smart-raise/src/app/home/home.module.ts'. Please add a @Pipe/@Directive/@component annotation.

How to solve the problem?

Weekdays aren't being styled properly

#I followed the README to get started, everything is default.

<ng2-flatpickr></ng2-flatpickr>

I think the problem is caused by an unexpected container: .flatpickr-weekdaycontainer

The problem is fixed by adding styles to that container class:

display: flex;
width: 100%;

screen shot 2018-04-05 at 1 58 52 pm

Here's what the relevant html structure looks like:

<div class="flatpickr-innerContainer">
    <div class="flatpickr-rContainer">
        <div class="flatpickr-weekdays">
            <div class="flatpickr-weekdaycontainer">
                <span class="flatpickr-weekday">Sun</span>
                <span class="flatpickr-weekday">Mon</span>
                <span class="flatpickr-weekday">Tue</span>
                <span class="flatpickr-weekday">Wed</span>
                <span class="flatpickr-weekday">Thu</span>
                <span class="flatpickr-weekday">Fri</span>
                <span class="flatpickr-weekday">Sat</span>
            </div>
        </div>
    </div>
</div>

ERROR TypeError: "this.flatpickrElement is undefined" in ngOnChanges

I am building an application that is based on Angular 8 and carbon-components-angular. Its DatePicker component (https://github.com/IBM/carbon-components-angular/blob/master/src/datepicker/datepicker.component.ts) uses ng2-flatpickr (at version 8.0.1). I am seeing the following error:

ERROR TypeError: "this.flatpickrElement is undefined"
ngOnChanges ng2-flatpickr.js:50

The reason in my opinion is an incorrectly set static flag of the flatpickrElement view child in https://github.com/mezoistvan/ng2-flatpickr/blob/master/src/ng2-flatpickr.component.ts#L39.

Given the child is not inside an ngIf and ngFor, it is static. Setting it to static=true resolves the issue for me.

IE9 compatibility?

Hi,

I know that this is an angular wrapper for flatpickr, and many of the functions still exist in the angular 2 version. But I was wondering if this was also IE9 compatible like the original flatpickr is.

Get Single Values

Hi!

Is it possible to get single values instead of an Array?!

The Api to which i'll send the form value only excepts single values...

br

formControlName not working

Firstly, thank you for porting flatpickr to ng2.

Today, we tried to hookup the ng2-flatpickr component using the following sytnax:

<ng2-flatpickr formControlName="campaign_end_date"></ng2-flatpickr>

I know 100% that our formControlName is initialised and setup correctly, due to testing with other components, but no matter what I try, I cannot seem to get the value out of the flatpickr component.

Am I missing something obvious? Your help would be greatly appreciated. Running "ng2-flatpickr": "^0.1.8" btw.

how to get formatted date

Hi, I have
public exampleOptions: FlatpickrOptions = { enableTime: true, dateFormat: 'd.m.Y H:i', };

and my HTML code looks like :
<ng2-flatpickr [config]="exampleOptions" [(ngModel)]="dateTime"></ng2-flatpickr>

but I get object instead of a string. something like : [Wed Oct 04 2017 12:00:00 GMT+0200 (Central European Daylight Time)].

How can I get formatted date string instead, in my typescript method?

Can it work with @angular/common@^4.2.4

Currently my Angular setup is running @angular/common@^4.2.4 in order to serve up a server-side angular app with angular Universal.

"dependencies": {
    "@angular/animations": "^4.2.4",
    "@angular/cli": "^1.3.0",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/platform-server": "^4.3.6",
    "@angular/router": "^4.2.4",
    "@nguniversal/express-engine": "^1.0.0-beta.3",
    "@nguniversal/module-map-ngfactory-loader": "^1.0.0-beta.3",
    ...
}

When building this project:

ERROR in Error: Metadata version mismatch for module ./node_modules/ng2-flatpickr/node_modules/@angular/common/common.d.ts, found version 4, expected 3, resolving symbol Ng2FlatpickrModule in ./node_modules/ng2-flatpickr/ng2-flatpickr.d.ts, resolving symbol Ng2FlatpickrModule in ./node_modules/ng2-flatpickr/ng2-flatpickr.d.ts

this is great!

Hey there! Really nice! love it.
Is it possible to add weeks?
Maybe also to have a timepicker included?
And maybe have a date-range-picker?

thanks!

On adding calendar in list, if list item is > 50 ,the UI response time become very slow.

Hi,

I am using the calendar in a list. Now if the list items length goes to a big number like 30 50 UI start unresponsive.

This list item code:

 <span class="task-list-item-hover-calender">
      <ng2-flatpickr  [placeholder]="translateKey('DUE DATE')" [config]="calendarConfig"></ng2-flatpickr>
      <img src="assets/images/app/due_date.svg" class="icon" (click)="toggleCalendar()" [alt]="translateKey('CALENDAR')" />
    </span> 

List code

  <div *ngIf="(filteredTaskData && filteredTaskData.length); else taskListEmpty">
          <app-task-panel-list-item [listItem]="taskItem" *ngFor="let taskItem of filteredTaskData;"></app-task-panel-list-item>
        </div>

Can you help me to resolve this unresponsiveness of UI?

Thanks

No provider for NgControl

Unhandled Promise rejection: Template parse errors:
No provider for NgControl ("

[ERROR ->]<ng2-flatpickr [config]="exampleOptions" formControlName="formControlName"></ng2-flatpickr>

</di"): GeoSearchComponent@39:4 ; Zone: ; Task: Promise.then ; Value: Error: Template parse errors:
No provider for NgControl ("

[ERROR ->]<ng2-flatpickr [config]="exampleOptions" formControlName="formControlName"></ng2-flatpickr>

</di"): GeoSearchComponent@39:4
at TemplateParser.parse (http://localhost:4200/main.bundle.js:57046:19)
at RuntimeCompiler._compileTemplate (http://localhost:4200/main.bundle.js:83418:51)
at http://localhost:4200/main.bundle.js:83323:83
at Set.forEach (native)
at compile (http://localhost:4200/main.bundle.js:83323:47)
at ZoneDelegate.invoke (http://localhost:4200/main.bundle.js:153953:26)
at Zone.run (http://localhost:4200/main.bundle.js:153835:43)
at http://localhost:4200/main.bundle.js:154223:57
at ZoneDelegate.invokeTask (http://localhost:4200/main.bundle.js:153986:35)
at Zone.runTask (http://localhost:4200/main.bundle.js:153875:47) Error: Template parse errors:
No provider for NgControl ("

[ERROR ->]<ng2-flatpickr [config]="exampleOptions" formControlName="formControlName"></ng2-flatpickr>

</di"): GeoSearchComponent@39:4
at TemplateParser.parse (http://localhost:4200/main.bundle.js:57046:19)
at RuntimeCompiler._compileTemplate (http://localhost:4200/main.bundle.js:83418:51)
at http://localhost:4200/main.bundle.js:83323:83
at Set.forEach (native)
at compile (http://localhost:4200/main.bundle.js:83323:47)
at ZoneDelegate.invoke (http://localhost:4200/main.bundle.js:153953:26)
at Zone.run (http://localhost:4200/main.bundle.js:153835:43)
at http://localhost:4200/main.bundle.js:154223:57
at ZoneDelegate.invokeTask (http://localhost:4200/main.bundle.js:153986:35)
at Zone.runTask (http://localhost:4200/main.bundle.js:153875:47)

Request for a directive

It would be nice if this package could also be provided with a directive so that we can use our own markup and not just the markup of the component.

Thank you!

locale problem

Hi,i just want to change the default language.there is a way?

Handling flatpickr hooks

Flatpickr documentation has a page with hooks

In their example you can use onChange to get selectedDates, dateStr, instance

onChange: function(selectedDates, dateStr, instance) {
        //...
},

Is there a way to use these hooks? A way I can access selectedDates, dateStr, instance? Or should just rely on input.value?

Thanks

Set a date programmatically

Hi! Nice work here!

One question: how do I programmatically set a date to update the input value?

Thank you

locale to the options

use locale options :
import Mandarin from 'flatpickr/dist/l10n/zh.js';
dateTimeOptions: FlatpickrOptions = {
enableTime: true,
locale: Mandarin.zh,
onChange: (e) => {

    }
}

ng build error:
ERROR in node_modules/flatpickr/dist/l10n/zh.d.ts(58,20): error TS1005: ';' expected.
node_modules/flatpickr/dist/l10n/zh.d.ts(58,21): error TS1003: Identifier expected.
node_modules/flatpickr/dist/l10n/zh.d.ts(58,39): error TS1005: ';' expected.

systemjs

hey there.
I had an issue getting it to work with system js. I had to change the import in ng2-flatpicker.component.js
import * as flatpickr from 'flatpickr/dist/flatpickr';
//require('flatpickr');

it would also be great to have a module which you can import and not declare it in ngmodules.
if you need any help let me know ๐Ÿ‘

inline mode

It is possible to use inline mode?
I tried but seem to receive an error:

Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.

Thanks

library comes with a copy of @angular/common

First I'll cover what I see, then why it's a problem.

When I npm install ng2-flatpickr I see that it comes with node_modules/@angular/common. This is strange because now I have:

  • <project path>/node_modules/@angular/common
  • <project path>/node_modules/ng2-flatpickr/node_modules/@angular/common

screen shot 2018-05-15 at 9 19 59 pm

I spot-checked about 10 other libraries and saw one other doing this. But it seems non-ideal to distribute @angular/common with your library. I guess it might be a build artifact.

This causes issue #32, which I reproduce with Angular 4 when trying to compile for AOT:

`Metadata version mismatch for module .../node_modules/ng2-flatpickr/node_modules/@angular/common/common.d.ts, found version 4, expected 3, resolving symbol Ng2FlatpickrModule in .../node_modules/ng2-flatpickr/ng2-flatpickr.d.ts, resolving symbol Ng2FlatpickrModule in .../node_modules/ng2-flatpickr/ng2-flatpickr.d.ts`

node_modules/ng2-flatpickr/node_modules/@angular/common/common.metadata.json has version 4 metadata, which only works with Angular 5+.
As a workaround, I can simply delete node_modules/ng2-flatpickr/node_modules, and then my app will compile.

build:ssr

I build my code with:
npm run build:ssr

run the server:
node dist/server.js

and get the following error

 node dist/server.js
/angular-client/dist/server.js:160615
        Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"])("design:type", HTMLElement)
                                                                                ^
ReferenceError: HTMLElement is not defined
    at /angular-client/dist/server.js:160615:81
at Module.<anonymous> (/.../angular-client/dist/server.js:160747:2)
    at __webpack_require__ (/.../angular-client/dist/server.js:20:30)
    at Object.ng2-flatpickr (/.../angular-client/dist/server.js:63977:18)

As you can see, it links to ng2-flatpickr

My related files in package.json:

"dependencies": {
    "@angular/common": "^7.1.0",
    "@angular/compiler": "^7.1.0",
    "@angular/core": "^7.1.0",
    "core-js": "^2.5.4",
    "flatpickr": "^4.6.1",
    "ng2-flatpickr": "^8.0.1",
    "rxjs": "^6.5.1",
    "rxjs-compat": "^6.5.1",
  },

Anyone else having the same issue? After doing some research earlier, I more or less ended up here: https://angular.io/api/core/Renderer2#description

For serverside rendering, it seems you need to use renderer2 and inject a document like this:

import { DOCUMENT } from '@angular/common';
import { Component, Inject, Renderer2 } from '@angular/core';
constructor(@Inject(DOCUMENT) document, r: Renderer2) {
    r.addClass(document.body, 'myclass');
 }

You already looked at Serverside rendering?

Setting an initial value with a formgroup yields no result

I'm creating a FormGroup with a field birthday and want to hook it up with a ng2-flatpickr component. If I select a date the formgroup now has the correct value. If I try to set an initial value with this.form.patchValue({ birthday: new Date() }); the flatpickr is empty. I would expect that the flatpickr shows the current date.

Here is my repro-repo: https://github.com/enko/ng2-flatpickr-problem

Relevant files are https://github.com/enko/ng2-flatpickr-problem/blob/master/src/app/app.component.ts and https://github.com/enko/ng2-flatpickr-problem/blob/master/src/app/app.component.html

How to use in modals

Hi mezoistvan,

I'm trying to use your code in my application, and it works well when I put it in any component view, but when I put inside a dialog it doesn't work, Am I missing something? I'm using angular-material for dialogs.

UPDATE..

I already know the problem... when I inspected the view with chrome, I realized that material-dialog creates a div with class="cdk-overlay-containe", with z-index=1000. The calendar view was behind this dialog, that's why I didn't see it.

Incompatibility with AOT

I was a little hasty a bit before. We might need to upgrade the packages to make it work with AOT.

Here's the error ๐Ÿ‘

ERROR in node_modules/rxjs/Subscription.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Subscription'.
node_modules/ng2-flatpickr/node_modules/@angular/common/src/location/location.d.ts(1,10): error TS2305: Module '"/usr/src/node_modules/rxjs/Subscription"' has no exported member 'ISubscription'.
node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.
node_modules/ng2-flatpickr/node_modules/@angular/common/src/pipes/async_pipe.d.ts(9,10): error TS2305: Module '"/usr/src/node_modules/rxjs/Observable"' has no exported member 'Observable'.

You should be able to update your packages like this :

...
  "devDependencies": {
    "@angular/core": "^6.0.1",
    "@angular/forms": "^6.0.1",
    "@types/node": "^10.0.8",
    "ng-packagr": "^2.4.4",
    "rxjs": "^6.1.0",
    "typescript": "2.7.x",
    "zone.js": "^0.8.26"
  },
...

I'm making a PR in parallel, but I think you might need to test it first.

ngModel

is there a way to define ngModel to time picker?

How to update locale on Locale change

Using redux and change locale should update all the labels etc.
Only thing that isn't updated is the flatpickr config while it is changed in the ngonchange.
Any ideas?

Cannot read property 'setDate' of undefined

Hi, there is a trouble in method setDateFromInput, on first method call there is no _flatpickr property in this.flatpickrElement.nativeElement;

Template:
<ng2-flatpickr [setDate]="mainOrder.controls.dateTime.value" [config]="dateTimePickerConfig" formControlName="dateTime"></ng2-flatpickr>

Error method:
this.flatpickrElement.nativeElement._flatpickr.setDate(date, true);
Can you add checking for _flatpickr in nativeElement?:) Thank you

Cannot read property 'setDate' of undefined
at Ng2FlatpickrComponent.setDateFromInput (ng2-flatpickr.es5.js:41)
at Ng2FlatpickrComponent.ngOnChanges (ng2-flatpickr.es5.js:61)
at checkAndUpdateDirectiveInline (core.js:12407)
at checkAndUpdateNodeInline (core.js:13935)
at checkAndUpdateNode (core.js:13878)
at debugCheckAndUpdateNode (core.js:14771)
at debugCheckDirectivesFn (core.js:14712)
at Object.eval [as updateDirectives] (LinkedOrderComponent.html:162)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:14697)
at checkAndUpdateView (core.js:13844)

The element ng2-flatpickr doesn't work inside ion-item element

I have form and inside there I use an ion-item element to structure the form. Basically something like this:

<form [formGroup]="labels" (ngSubmit)="logForm()">
        <ion-item>
            <ion-label>Time Date:</ion-label>
            <ng2-flatpickr formControlName="time_date"></ng2-flatpickr>
        </ion-item>
</form>

But the ng2-flatpickr doesn't get render when its inside the ion-item tag. It only renders when its outside. I was wondering why is that the case?

Any help would be greatly appreciated. Thanks :)

Syntax Error in IE11 and below.

Hello,

I'm getting a syntax error on your plugin in IE11 in both my app and your examples, and can reproduce across multiple machines. Is this a known issue? If so, is there a hotfix either you or I can do to make it work?

Error: Cannot find module 'ng2-flatpickr'

On Angular 6 with AOT I get this error. I wish I could provide more details but I don't really know what is happening. The package is definitely installed! Reverting to 7.0.3 solves it for now.

Calendar range

I don't believe we have support for data-date-picker-input-from and data-date-picker-input-to, which allows having two inputs far a range selection

two copies of ng2-flatpickr on one template

Here is a code when the component is first displayed, thinks for a long time, pours errors into the console. Then in 3-5 seconds there are calendars.
when [setDate] = "xxxx" in one instance, then everything is fine.
In two copies of the delay and error
I write so thoughts in the ear

<td>
    <div class="divTableCell">
        <ng2-flatpickr  [setDate]="DateStart" [config]="exampleOptions" (change)="onChangeDateStart($event)"></ng2-flatpickr>
    </div>
</td>
<td>
    <div class="divTableCell">
        <ng2-flatpickr  [setDate]="DateEnd"  [config]="exampleOptions" (change)="onChangeDatePickerEnd($event)"></ng2-flatpickr>
    </div>
</td>

ngOnInit() {
this.DateStart = new Date(this.item.timeStart.substr(0, 10));
this.DateEnd = new Date(this.item.timeEnd.substr(0, 10));
}

formControlName doesn't work.

here s my code:

dateOptions: FlatpickrOptions = {
defaultDate: new Date(),
locale: Pt.pt,
dateFormat:'d/m/Y'
};

myForm = formBuilder.group({
...
dtaInicio : [''],
dtaFim : [''],
});
<ng2-flatpickr formControlName="dtaInicio" [config]="dateOptions" >

myForm.value.dtaInicio and myForm.value.dtaFim comes always empty!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.