1

I have created a demo here: https://stackblitz.com/edit/angular-ivy-8bvyfh?file=src/app/app.module.ts

I created mat-date-range-input, which works with MomentDateAdapter. When I select days from different months all fine: enter image description here

But if I select days from the same month, it's expected, that month will be omitted. So instead of: enter image description here

I would like to see: "24 - 27 October". How can I achieve it?

0

1 Answer 1

3

Demo in this Stackblitz Link

One work around is you can replace text from input using template reference variable.

  <mat-date-range-input [rangePicker]="picker">
   <input
     #dateRangeStart
      matStartDate
      placeholder="Start date"
      (blur)="dateRangeChange(dateRangeStart, dateRangeEnd)"
      (dateChange)="dateRangeChange(dateRangeStart, dateRangeEnd)"
    />
    <input
      matEndDate
      placeholder="End date"
      #dateRangeEnd
      (dateChange)="dateRangeChange(dateRangeStart, dateRangeEnd)"
    />
  />

and then inside component.ts file you can do like this

  dateRangeChange(s, e) {
    s.value = s.value.split(' ')[0];
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.