Angular 6 and bootstrap 4: date picker

The Dead Man picture The Dead Man · Jul 5, 2018 · Viewed 18.8k times · Source

I have a form which contain a date picker / calender, email, city name and hotel name, I want a user to select a date and enter other fields and submit the data.

This is what I have.

HTML:

 <form [formGroup]="angForm" class="form-element">
        <div class="form-group">
          <label for="dateOfBirth">Date of Birth</label>
          <input id="dateOfBirth" name="dateOfBirth" [(ngModel)]="dateOfBirth" type="text" bsDatepicker class="form-control" />
        </div>

        <div class="form-group form-element_email">
          <input type="email" class="form-control info" placeholder="Email" formControlName="email" #email (ngModelChange)="onChange($event)">
        </div>
        <div *ngIf="angForm.controls['email'].invalid && (angForm.controls['email'].dirty || angForm.controls['email'].touched)"
          class="alert alert-danger">
          <div *ngIf="angForm.controls['email'].errors.required">
            Email is required.
          </div>
        </div>
        <div class="input-group mb-3 form-element_city">
          <select class="custom-select" id="inputGroupSelect01" #cityName>
            <option selected *ngFor="let city of cities" [ngValue]="city.name">{{city.name}}</option>

          </select>
        </div>
        <div class="input-group mb-3 form-element_hotel">
          <select class="custom-select" id="inputGroupSelect01" #hotelName>
            <option selected *ngFor="let hotel of hotels" [ngValue]="hotel.name">{{hotel.name}}</option>

          </select>
        </div>
        <div class="form-group">
          <button type="submit" (click)="addReview(email.value, cityName.value , hotelName.value)" class="btn btn-primary btn-block form-element_btn"
            [disabled]="!validEmail">Book</button>
        </div>
      </form>

This dispalys the following result: wrong one

enter image description here

Instead of that input with date picker , I just want the full calender to be display on the left side ,

Here is what I want . Good one

enter image description here

I tried many solution online I could not be able to solve my problem,

What do I need to change in my code to get the result I want? please Am newbie though, thanks

Answer

Joklogh picture Joklogh · Jul 13, 2018

You can actually provide placement in the element which uses bdDatepicker directive. Just set this placement property to left value. Here is example in documentation. https://valor-software.com/ngx-bootstrap/#/datepicker#placement