Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datepicker for Angular 4

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.

like image 703
Deimos620 Avatar asked Sep 18 '25 03:09

Deimos620


1 Answers

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 {}
like image 98
Melchia Avatar answered Sep 20 '25 17:09

Melchia