Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confirmDatePlugins using with angular5 #1272

Closed
Picktarget opened this issue Mar 3, 2018 · 16 comments
Closed

confirmDatePlugins using with angular5 #1272

Picktarget opened this issue Mar 3, 2018 · 16 comments

Comments

@Picktarget
Copy link

when I follow the example in plugins page of documentation,tslint told me error TS2350: Only a void function can be called with the 'new' keyword. how can i resolve it.

private opt = {
confirmIcon: '',
confirmText: 'OK ',
showAlways: true,
theme: 'light'
}
public config = {
wrap: true, enableTime: true,
locale: Mandarin,
dateFormat: 'Y-m-d H:i',
altInput: false,
time_24hr: true,
minDate: new Date(),
plugins: [new confirmDatePlugin(this.opt)]

Your Environment

  • flatpickr version used: latest
  • Browser name and version: chrome latest
  • OS and version: windows
@chmln
Copy link
Member

chmln commented Mar 3, 2018

@Picktarget just omit the "new" keyword. The plugin will work regardless

@chmln chmln closed this as completed Mar 3, 2018
@Picktarget
Copy link
Author

yeah I just use plugins: [confirmDatePlugin(this.opt)],then the browser told me
TypeError: confirmDate_1.default is not a function
at LiveComponent.ngAfterViewInit
I just use flatpickr in ngAfterViewInit and import like this
import confirmDatePlugin from 'flatpickr/dist/plugins/confirmDate/confirmDate';
import 'flatpickr/dist/plugins/confirmDate/confirmDate.css';
ngAfterViewInit() {
const element1 = this.el.nativeElement.querySelector('#livein_flatpickr');
if (element1) {
const calendars_1 = flatpickr(element1, {
wrap: true, enableTime: true,
locale: Mandarin,
dateFormat: 'Y-m-d H:i',
altInput: false,
time_24hr: true,
minDate: new Date(),
plugins: [confirmDatePlugin({ confirmText: 'OK' })]
});
}
what's the reason,please?

@chmln
Copy link
Member

chmln commented Mar 4, 2018

@Picktarget try

import * as  confirmDatePlugin from 'flatpickr/dist/plugins/confirmDate/confirmDate';

@chmln chmln reopened this Mar 4, 2018
@Picktarget
Copy link
Author

but how I use [confirmDatePlugin({ confirmText: 'OK' })]?

@chmln
Copy link
Member

chmln commented Mar 4, 2018

@Picktarget the same way

@Picktarget
Copy link
Author

Picktarget commented Mar 4, 2018

error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof' flatpickr/dist/plugins/confirmDate/confir...' has no compatible call signatures.
with using
plugins: [confirmDatePlugin({
confirmIcon: '',
confirmText: 'OK ',
showAlways: true,
theme: 'light'
})]

@chmln
Copy link
Member

chmln commented Mar 4, 2018

@Picktarget okay, try this:

import  confirmDatePlugin from 'flatpickr/src/plugins/confirmDate/confirmDate';

@Picktarget
Copy link
Author

there is no directory named plugins under the src . then I use npm i --save

qq 20180304103219

@Picktarget
Copy link
Author

should I download the source_code.zip for using?

@chmln
Copy link
Member

chmln commented Mar 4, 2018

@Picktarget No. I will investigate this myself and update the issue when I find a solution :)

For now, try using require() instead of importing to avoid type errors.

@Picktarget
Copy link
Author

ok thanks for ur help,best wishes to u!

@Picktarget
Copy link
Author

hey man!what's going on,please?

@chmln
Copy link
Member

chmln commented Mar 26, 2018

@Picktarget this is now fixed in v4.4

@Picktarget
Copy link
Author

Thanks a lot.How should I use it?Just following the development documentation?

@chmln
Copy link
Member

chmln commented Mar 29, 2018

@Picktarget yes. just import it like normal (import flatpickr from "flatpickr") and call it like normal. The rest is in the documentation.

Let me know if you can't figure this out.
And feel free to create new issues if the docs are unclear or if you face other problems :)

@chmln chmln closed this as completed Mar 29, 2018
@Picktarget
Copy link
Author

ok,thanks for ur generosity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants