Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

There is no directive with "exportAs" set to "ngbDatepicker"

Tags:

angular

I'm using angular 4, i was trying to add datepicker while i'm using datepicker-popup.html I'm getting error as given below. I'm not getting what kind of error it is. please help me out. enter image description here

datepicker-popup.html

<form class="form-inline">
    <div class="form-group">
        <div class="input-group">
            <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>
    </div>
</form>

<hr/>
<pre>Model: {{ model | json }}</pre>
like image 636
Soumya Ranjan Das Avatar asked Aug 23 '18 07:08

Soumya Ranjan Das


2 Answers

Please add these two lines in your file.

import { NgbDate, NgbModule } from '@ng-bootstrap/ng-bootstrap';

and import the NgbModule.

imports: [NgbModule]
like image 107
Santosh Singh Avatar answered Sep 22 '22 05:09

Santosh Singh


I found this solution:

In HTML:

<input class="form-control" placeholder="yyyy-mm-dd" name="dp" formControlName="dp" ngbDatepicker>

In TS:

@ViewChild('NgbdDatepicker') d: NgbDateStruct;
like image 45
oswaldo ortega Avatar answered Sep 23 '22 05:09

oswaldo ortega