amandeep
amandeep

Reputation: 17

Prime-Ng p-dropdown not showing selected value after refresh

I am using prime-ng p-drop to select a value and post it to DB. I am able to select a value and can post it to DB. but if i refresh the page, i dont see selcected value and its always the showing the top value from the list. below is my code. Would appreciate any help. TIA

          <p-dropdown  [options]="countries" [(ngModel)]="dataelement.jobDataElementValue"
            (onChange)="jobControlsValueChange($event,dataelement?.jobDataElementName,'dropdown')"
            [filter]="true" optionLabel="name" filterBy="name" >

              <ng-template pTemplate="selectedItem">
                  <div >
                    <div>{{ dataelement.jobDataElementValue.name}}</div>
                  </div>
              </ng-template>
              <ng-template let-dropdownvalues pTemplate="item">
                  <div >
                       <div>{{dropdownvalues.name}}</div>
                  </div>
              </ng-template>
          </p-dropdown>

Upvotes: -1

Views: 5559

Answers (1)

amandeep
amandeep

Reputation: 17

In case someone looking for answer

<p-dropdown  [options]="countries" [(ngModel)]="dataelement.jobDataElementValue"
            (onChange)="jobControlsValueChange($event,dataelement?.jobDataElementName,'dropdown')"
            [filter]="true" optionLabel="name" optionValue="name" filterBy="name" >

              <ng-template pTemplate="selectedItem">
                  <div >
                    <div>{{ dataelement.jobDataElementValue}}</div>
                  </div>
              </ng-template>
              <ng-template let-dropdownvalues pTemplate="item">
                  <div >
                       <div>{{dropdownvalues.name}}</div>
                  </div>
              </ng-template>
</p-dropdown>

Upvotes: 0

Related Questions