Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

309
Visualizações
Error: Unexpected module 'DatePickerModule' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation

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

Installation was successful. So now, I imported the DatePickerModule module in 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'. Please add a @Pipe/@Directive/@Component annotation.

I am new to Angular2 by the way.

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Why are you putting your DatePickerModule in providers. Only services needs to be put in there angular create the instance of the service when the application is bootstrapped.

about 4 years ago · Santiago Trujillo Relatório

0

Check for missing reference in the import statement in module.ts file. If you have in your component:

import { DatePickerModule,SomeOtherModule } from 'somewhere';

in module.ts file you must have the same import

import { DatePickerModule,SomeOtherModule } from 'somewhere';

If you have only

import { DatePickerModule } from 'somewhere';

or you don't have the import statement then this error will be thrown because you did not add "SomeOtherModule" to the import statement.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda