Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ngAfterViewInit(): void {
// add attr data-input, mandatory for the picker to work in wrap mode
this.renderer.setElementAttribute(this.inputElement.nativeElement, 'data-input', '');
// disabled case
if (this.disabled === true) {
this.model.control.disable()
}
const navigatorLanguage = navigator.language.split('-')[0];
let datePickerLocale = {};
if (navigatorLanguage === 'fr') {
datePickerLocale = French.fr;
}
// options for the flatpickr instance
let options = {
altInput: !this.disabled,
altFormat: 'd/m/Y', // date format displayed to user
dateFormat: 'Y-m-d', // date format sent to server
allowInput: false,
enableTime: this.enableTime,
minDate: this.minDate,
maxDate: this.maxDate,
clickOpens: !this.disabled,
wrap: true, // to add input decoration (calendar icon and delete icon)
locale: datePickerLocale
}