How to use eonasdan-bootstrap-datetimepicker library with angular 6? I would like to setup default options.
Here is the link to the library: https://github.com/Eonasdan/bootstrap-datetimepicker
Here is the code:
import * as $ from 'jquery';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
constructor() {
$.fn.datetimepicker.defaults.keepInvalid = true;
$.fn.datetimepicker.defaults.useStrict = true;
$.fn.datetimepicker.defaults.useCurrent = false;
$.fn.datetimepicker.defaults.format = "MM/DD/YYYY";
$.fn.datetimepicker.defaults.keyBinds["delete"] = null;
$.fn.datetimepicker.defaults.icons = {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-angle-up',
down: 'fa fa-angle-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'glyphicon glyphicon-screenshot',
clear: 'fa fa-trash-o',
close: 'fa fa-window-close'
}
}
}
I get the following error
Property 'datetimepicker' does not exist on type 'JQuery<HTMLElement>'
I am late to the game, but the answer is to add the @types/jquery.ui.datetimepicker package to your project. Since I use yarn, I did
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With