kesarion / angular2-air-datepicker

Angular2 Datepicker | Native implementation of air-datepicker
http://t1m0n.name/air-datepicker/docs/
MIT License
16 stars 10 forks source link

Getting ERROR in AirDatepicker is not an NgModule #5

Closed winni4eva closed 7 years ago

winni4eva commented 7 years ago
      I get the error ERROR in AirDatepicker is not an NgModule when I try to run ng build

     ---These are my package json depencies---
    "dependencies": {
    "@angular/animations": "^4.0.3",
     "@angular/cli": "^1.0.0",
     "@angular/common": "~4.0.0",
    "@angular/compiler": "~4.0.0",
    "@angular/core": "~4.0.0",
    "@angular/forms": "~4.0.0",
    "@angular/http": "~4.0.0",
    "@angular/material": "^2.0.0-beta.2",
    "@angular/platform-browser": "~4.0.0",
    "@angular/platform-browser-dynamic": "~4.0.0",
    "@angular/router": "~4.0.0",
    "angular2-air-datepicker": "^0.1.2",
   }

  ---I declared the Module in typings.d.ts---
 declare module 'angular2-air-datepicker';

 --And Loaded it In mY app.module--
 import { AirDatepicker } from 'angular2-air-datepicker';

imports: [
    BrowserModule,
    FormsModule,
    ReactiveFormsModule,
    BrowserAnimationsModule,
    HttpModule,
    routing,
    AirDatepicker,
 ],
kesarion commented 7 years ago

@winni4eva Indeed, AirDatepicker is not a module, it's a component :)

As described on the github page and in the package readme, you should include it in your module declarations:

import { NgModule } from "@angular/core";
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { MyComponent } from "./my.component";
import { AirDatepicker } from 'angular2-air-datepicker';

@NgModule({
    imports: [
        CommonModule,
        FormsModule
    ],
    declarations: [
        MyComponent,
        AirDatepicker
    ]
})
export class HomeModule {}
winni4eva commented 7 years ago

Thanks kesarion..