1

I have components in the date selector, I need to make the service listen to date changes in the input and pass these values to another component by default

day-header.component.ts

(this is the component where I want to listen for input changes)

      <div class="day-header__select">
        <tui-svg (click)="previous()" class="day-header__icon" src="tuiIconChevronLeftLarge"></tui-svg>
        <tui-input-date data-appearance="textfield" class="day-header__input"
                        [formControl]="control"
                        [tuiTextfieldCleaner]="true"
        >
          Choose a day
          <input data-appearance="textfield" tuiTextfield/>
        </tui-input-date>
        <tui-svg (click)="next()" class="day-header__icon" src="tuiIconChevronRightLarge"></tui-svg>
      </div>

view-task.component.ts

(this is the component where I want to get the value to insert it into moment())

private getTasks(): void {
    this.httpService.getDaySchedule(Periods.Day, moment('2022-06-29').utc().toDate()).pipe(
      tap((tasks: ITaskResponse[]) => {
        this.tasks$.next(tasks);
        this.isLoading$.next(false);
      }),
      catchError((error) => {
        this.alertService.createErrorAlert(error.error.message);
        return EMPTY;
      }),
      takeUntil(this.ngUnsubscribe$),
    ).subscribe();
  }
qwfrjk
  • 71
  • 2
  • 10
  • 1
    Read my answer on updating the values from one component to another using service. Modify it to your use. https://stackoverflow.com/a/63935918/8070068 – Swapnil Sourabh Jun 29 '22 at 09:56

0 Answers0