Spend the month and year when the user clicks

Asked

Viewed 43 times

-1

I have this input, that I would like to click I spend the day, month and year that will appear, and not the current month, I will need to make a condition, that I already have ready, but I do not know how to pass to this input

<input matInput [matDatepicker]="paymentDate_i"
       placeholder="{{ 'fields.paymentDate' | translate }}" formControlName="paymentDate"
       name="paymentDate-{{ i }}" (focus)="paymentDate_i.open()" (click)="paymentDate_i.open()"
       required />

I don’t want the date to appear, I want that when clicking, I came with the month and year that I put.

1 answer

1


You can use the Component mat-datepicker to obtain the desired result.

<input matInput  [matDatepicker]="picker">
<mat-datepicker startAt="2018-01-15" #picker></mat-datepicker>

Functional example: datepicker

  • 1

    Thanks for the tip, it worked right.. Thank you,

  • Yes, change the template to <mat-datepicker [startAt]="myStartAt" #picker></mat-datepicker>. And add the variable in the Component myStartAt = new Date("2018-01-05")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.