Want to call options of p-dropdown dynamically method keeps on executing #1924
Replies: 1 comment
-
Hi, Could you please share a stackblitz example so we can identify the issue clearly? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
------code
@if(report!==undefined && report!==null){
<div class="p-fluid p-formgrid grid mt-2 mb-2" *ngFor="let rep of report" >
{{rep.healtH_ASSESSMENT_QUESTIONS?.hsQ_QUESTION_TEXT}}
@if(rep.healtH_ASSESSMENT_QUESTIONS.hsQ_DISPLAY_TYPE=='txts') {
<input pInputText id="name3" type="text" [(ngModel)]="rep.ptR_RESPONSE_VALUE" />}
@if(rep.healtH_ASSESSMENT_QUESTIONS.hsQ_DISPLAY_TYPE=='txtl') {
<textarea pInputTextarea id="name3" type="text" [(ngModel)]="rep.ptR_RESPONSE_VALUE" ></textarea>}
@if(rep.healtH_ASSESSMENT_QUESTIONS.hsQ_DISPLAY_TYPE=='ddl') {
<p-dropdown [options]="getDropdownOptions(rep.healtH_ASSESSMENT_QUESTIONS.hsQ_HQR_ID)">
}
@if(rep.healtH_ASSESSMENT_QUESTIONS.hsQ_QC_FLAG_DONE=='Yes') {
<p-dropdown [options]="options" optionLabel="label" optionValue="value" [style]="{'width':'100%'}">
}
-----ts
ViewReport(number1:any,number2:any){
this.http.get(baseurl+"Patient/GetReport?PTS_ID="+number1+"&PTR_HAA_ID="+number2).subscribe(res=>{
this.report=res;
console.log(this.report);
res.forEach((element:any) => {
if(element.healtH_ASSESSMENT_QUESTIONS.hsQ_HQR_ID!==null){
this.http.get<any[]>(baseurl + 'Patient/GetResponseCode?HQR_RESPONSE_CODE=' + element.healtH_ASSESSMENT_QUESTIONS.hsQ_HQR_ID).subscribe(res => {
this.dropdownOptionsMap[element.healtH_ASSESSMENT_QUESTIONS.hsQ_HQR_ID] = res.map((item: any) => ({ label: item.text, value: item.value }));
});
}});
})
}
getDropdownOptions(hsQ_HQR_ID: string): any[] | undefined {
console.log( this.dropdownOptionsMap[hsQ_HQR_ID])
return this.dropdownOptionsMap[hsQ_HQR_ID];
}
Beta Was this translation helpful? Give feedback.
All reactions