用于 flatpickr 的 Angular 2+ 封装 (https://GitHub.com/chmln/flatpickr)
用于 flatpickr 的 Angular 2+ 封装 (https://GitHub.com/chmln/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-flatpickrImport the Ng2FlatpickrModule to your NgModule:
import { Ng2FlatpickrModule } from 'ng2-flatpickr';
@NgModule({
imports: [
Ng2FlatpickrModule
...Example usage in a form component html template:
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'
};
Add locale to the options
import { FlatpickrOptions } from 'ng2-flatpickr';
import Russian from 'flatpickr/dist/l10n/ru.js';
let exampleOptions: FlatpickrOptions = {
locale: Russian.ru,
...
};
Set a placeholder for the input:
Set a date using a string or a date object:
let randomDateString = '1988-09-19';
let randomDateObject = new Date( 1234567891011 );
Flatpickr css needs to be loaded separately. when using @angular/cli, load it in angular.json.
"styles": [
"node_modules/flatpickr/dist/flatpickr.min.css"
]暂无开放 Issues,或尚未同步最近议题。