Victor
Victor

Reputation: 13

How to properly connect the ng2-datepicker component in angular 2 app

Ng2-datepicker (1.0.6) Angular2 (2.0.0-rc.5)

When i try to use it in html as in their docs i got this error:

    zone.js:484 Unhandled Promise rejection: Template parse errors:
    Can't bind to 'ngModel' since it isn't a known property of 'datepicker'.
    ("
    </div>
    <div class="form-input">
        <datepicker [ERROR ->][(ngModel)]="notice.date"></datepicker>
    </div>
  </div>
    "): AddNoticeComponent@17:24 ; Zone: <root> ; Task: Promise.then ; Value: 

Upvotes: 1

Views: 1040

Answers (2)

Please add below code in .ts file

import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
@NgModule({
  declarations: [
  ],
  imports: [   
    FormsModule,
    HttpModule,
  ],
})

Upvotes: 0

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657048

Add it to declarations: [...] of an @NgModule() and also add imports: [CommonModule, FormsModule, ReactiveFormsModule] to this @NgModule()

Upvotes: 0

Related Questions