Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-bootstrap Datepicker current date like placeholder

I use ng-bootstrap Datepicker something like here: plnkr example

<div class="input-group">
  <input class="form-control" placeholder="yyyy-mm-dd"
         name="dp" [(ngModel)]="model" ngbDatepicker #d="ngbDatepicker">
  <div class="input-group-addon" (click)="d.toggle()" >
    <img src="img/calendar-icon.svg" style="width: 1.2rem; height: 1rem; cursor: pointer;"/>
  </div>
</div>

and I would like have placeholder as current date instead yyyy-mm-dd. For example today 23.10.2016. It is possible or how can i do that.

like image 923
Marko Avatar asked Oct 23 '16 13:10

Marko


1 Answers

You can do like this-

In component, defined date like this-

valuedate = new Date();

In template html, change placeholder like this-

placeholder="{{valuedate | date: 'yyyy-MM-dd'}}"

Result:

date placeholder

like image 51
Sanket Avatar answered Sep 28 '22 08:09

Sanket