Reputation: 301
I am trying to add datepicker to Angular 4 based application. I tried to use ng2-datepicker. After install ng2-datepicker via npm I imported module like this:
import {DatePickerModule} from 'ng2-datepicker-bootstrap';
But webpack says can not find DatePickerModule. And I've tried to use ng2-eonasdan-datetimepicker, I imported it in app.module.ts like this:
import {A2Edatetimepicker} from 'ng2-eonasdan-datetimepicker';
@NgModule({
imports: [
A2Edatetimepicker
]
})
and webpack says:
ERROR in A2Edatetimepicker is not an NgModule
I am not sure what's wrong. Is there any cool datepicker for Angular 4? Or Did I do something wrong? Please, help me to fix this problem.
Upvotes: 4
Views: 8539
Reputation: 36
Check out this npm package. It allows you to just simply add a directive to your input or element and is designed for both single and date range.
<input type="text" placeholder="Input Date" date-picker (dateselected)="dateSelected($event)" />
Upvotes: 0
Reputation: 24224
run
npm install ng2-datepicker --save
then in your root module:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgDatepickerModule } from 'ng2-datepicker';
@NgModule({
imports: [
BrowserModule,
NgDatepickerModule
],
declarations: [ AppComponent ],
exports: [ AppComponent ]
})
export class AppModule {}
Upvotes: 3