Error: unexpected module "DatePickerModule" declared by the module "AppModule". Add @ Pipe / @ Directive / @ Component Note

I want to use the DatePickerModule from Angular in my application. So I installed the package as follows: npm install ng2-datepicker-bootstrap --save

Installation was successful. So now I have imported the DatePickerModule module into my AppModule, as shown below:

import { DatePickerModule } from 'ng2-datepicker-bootstrap';

@NgModule({

  declarations: [
    other Components......,
    DatePickerModule
  ],
  imports: [
    ........
  ],
  providers: [Service, DatePickerModule],
  bootstrap: [AppComponent]
})

export class AppModule { }

Then use the code below in my info.component.html .

<datepicker [(ngModel)]="model.firstDate" [viewFormat]="'DD/MM/YYYY'" [modelFormat]="'YYYY-MM-DD'"  [id]="'firstDate'" [label]="'To'"></datepicker> 

But when I run the project, I got this error: Error: unexpected module 'DatePickerModule' declared by the module 'AppModule'. Add a note @ Pipe / @ Directive / @ Component.

I am new to Angular2.

+4
2

DatePickerModule . angular , .

+1

import module.ts. :

import { DatePickerModule,SomeOtherModule } from 'somewhere';

module.ts

import { DatePickerModule,SomeOtherModule } from 'somewhere';

import { DatePickerModule } from 'somewhere';

, "SomeOtherModule" import.

0

Source: https://habr.com/ru/post/1676101/


All Articles