E
E
Eugene2019-02-05 23:58:22
Angular
Eugene, 2019-02-05 23:58:22

How to get date from child component Date Time Picker and put into input of angular parent component?

Good day.
You need to pick up the selected date in the Bootstrap DateTimePicker calendar and paste it into input. Sounds simple, but the difficulty is that the input calendar is a different component.
There is a parent component "date.component" and a child "dl-date-time-picker"
date.component

<input 
                type="text" 
                autocomplete="off"
                name="DateTo"
                [textMask]="{mask: maskDateTime}"
  />

  <dl-date-time-picker 
                startView="year" 
                maxView="year" 
                minView="minute" 
                minuteStep="5" 
                [(ngModel)]="selectFilter"
                >
  </dl-date-time-picker>

How can I pull the selected date in the calendar and insert it into the parent component's input?
Here is the calendar itself https://dalelotts.github.io/angular-bootstrap-date...
That is, you need to take the date from the calendar, insert it into the input field for further filtering by the selected date.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Q
Qairat, 2019-02-08
@Qairat

If you look at the calendar, then there is `@Output()
readonly change = new EventEmitter>();`
it must be added
then in .ts file:

date;
  getDate(event) {
     this.date = event;
  }

and in the template:
Something like this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question