ngbDatepicker из ng-bootstrap не работает - PullRequest
0 голосов
/ 26 мая 2018

Я следовал упомянутому решению здесь все еще получаю исключение

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)

Мой 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>
...