1

I followed the solution mentioned here still I am getting the exception

Uncaught Error: Template parse errors:
There is no directive with "exportAs" set to "ngbDatepicker" ("   <input class="form-control" placeholder="yyyy-mm-dd" name="dp" [(ngModel)]="model" ngbDatepicker [ERROR ->]#d="ngbDatepicker">
          <div class="input-group-append">
         <button class="btn btn-out"): ng:///LayoutModule/StudentComponent.html@34:107
Can't bind to 'ngModel' since it isn't a known property of 'input'. ("    <div class="col-sm-3">
         <input class="form-control" placeholder="yyyy-mm-dd" name="dp" [ERROR ->][(ngModel)]="model" ngbDatepicker #d="ngbDatepicker">
         <div class="input-group-append">
"): ng:///LayoutModule/StudentComponent.html@34:73
at syntaxError (compiler.js:215)
at TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:14705)

My app.module.ts

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule, Injectable } from '@angular/core';
    import { FormsModule } from '@angular/forms';
    import { Router, Routes, RouterModule, CanActivateChild, 
    ActivatedRouteSnapshot, RouterStateSnapshot } from "@angular/router";
    import { Observable } from 'rxjs';
    import { NgbModal, NgbModule } from '@ng-bootstrap/ng-bootstrap';

    @NgModule({
    imports: [   
    BrowserModule,
    HttpClientModule,
    HeaderModule,
    LayoutModule,
    FormsModule  ,
    NgbModule.forRoot(),
    RouterModule.forRoot(routes, {useHash: true}),  
  ],
  declarations: [///declare components here]
 })

html

<div class="col-sm-1">
      <label for="dob">DOB</label>
    </div>
    <div class="col-sm-3">
      <input class="form-control" placeholder="yyyy-mm-dd" name="dp" [(ngModel)]="model" ngbDatepicker #d="ngbDatepicker">
      <div class="input-group-append">
        <button class="btn btn-outline-secondary" (click)="d.toggle()" type="button">
          <img src="img/calendar-icon.svg" style="width: 1.2rem; height: 1rem; cursor: pointer;" />
        </button>
      </div>
    </div>
Niladri
  • 5,832
  • 2
  • 23
  • 41
Sajin Surendran
  • 248
  • 6
  • 17
  • are you using the directive in any child module? – Niladri May 28 '18 at 10:23
  • have same issue ,yes using a directive in a child module , event i made ngbdatepicker to available as global like this , NgbDatepickerModule.forRoot() at imports at app.module.ts – AhammadaliPK Jul 26 '18 at 04:46

0 Answers0