I am working on a project that involves two dropdown menus. The options for the first dropdown menu are stored in a file called constant.ts
. Depending on the selection made in the first dropdown, the options for the second dropdown will change accordingly.
.constant.ts
export const ActionRecordConstant = {
contact: 'Contact1',
about: 'About',
};
.component.ts
public getCodes() {
let baseUrl = `/api end point`;
this._restfulService
.restfulGetData(baseUrl)
.subscribe(
(actionLookupData: ActionLookupData) => {
if (actionLookupData) {
this.contactCodes = actionLookupData.contactCodes;
this.aboutCodes = actionLookupData.aboutCodes;
}
},
(err) => {
console.error(err);
},
);
}
public contactSelect(data: any) {
this.contactId = data;
}
public aboutSelect(data: any) {
this.aboutId = data;
}
.component.html
<div class="row mt-15">
<div class="form-group">
<div class="col-sm-3">
<label> <b>Contact</b></label>
</div>
<div class="col-sm-7">
<select class="form-control">
<option value="" disabled [selected]="true"></option>
<option>About</option>
<option>Contact</option>
</select>
</div>
</div>
</div>
<div class="row mt-15">
<div class="form-group">
<div class="col-sm-3">
<label> <b>Action</b></label>
</div>
<div class="col-sm-7">
<select>
<option value="" disabled [selected]="true"></option>
<option>//code</option>
</select>
</div>
</div>
</div>
I need to implement functionality where selecting an option from the first dropdown will dynamically populate the options in the second dropdown based on the selection made.