AngularJS 2 DateTime Picker
-
install ng2-datetime-picker
$ npm install ng2-datetime-picker --save
-
add
map
andpackages
to yoursystemjs.config.js
map['ng2-datetime-picker'] = 'node_modules/ng2-datetime-picker'; // map['ng2-datetime-picker'] = 'https://npmcdn.com/ng2-datetime-picker'; // or without npm installation packages['ng2-datetime-picker'] = { main: 'dist/index.js', defaultExtension: 'js'
-
import and add directive in your component
import {DateTimePickerDirective} from "ng2-datetime-picker"; ... @Component({ directives: [DateTimePickerDirective], .. });
-
You are ready. use it in your template
<input [(ngModel)]="date1" datetime-picker date-only="true" />
All options are optional except ngModel
- ngModel, date variable
- year, e.g., 2016, default: current year
- month, e.g., 6, default: current month
- day, e.g., 13, default: current day
- hour, e.g. 23, default: current hour
- minute e.g. 59, default: current minute
- date-format, Angular2 DatePipe date format default: 'yMd'
- date-only, true or false, default is false
- close-on-select, true or false. indicates to close datetime-picker when select a date. default: true
$ git clone https://github.com/ng2-ui/ng2-datetime-picker.git
$ cd ng2-datetime-picker
$ npm install
$ npm start