Imagine there's a dropdown menu in my application, with options like "WORK", "RELEASE", and "OPEN". There's also a calendar field that is initially empty. When I choose the option "RELEASE" from the dropdown menu, I want it to automatically select today's date on the calendar field. The code snippet for this scenario can be found in form.component.html:
<form [formGroup]="form">
<div class="flex">
<div class="col-3">
<div class="flex flex-row align-items-center">
<label class="col-6">Status</label>
<p-dropdown
[options]="workStatus"
[showClear]="true"
formControlName="workingStatus"
class="col-6">
</p-dropdown>
</div>
<div class="flex flex-row align-items-center">
<label class="col-6">Date</label>
<p-calendar formControlName="getWorkDate"
dateFormat="dd-mm-yyyy"
dataType="localdate"
appendTo="body"
class="col-6">
</p-calendar>
To ensure that today's date is selected on the calendar, I have implemented a function in form.component.ts:
selectTodaysDate(DateToday: number[]) {
const todayDate = new Date().getDate();
this.form.patchValue({getWorkDate: DateToday.find(today => today == todayDate)});
}
Now, the challenge lies in triggering the dropdown menu when "RELEASE" is selected. How can I achieve this interactivity?