2

How to get the text name of selected dropdown value.

Using a prime ng dropdown

HTML

   <p-dropdown [options]="regionSelectList" [(ngModel)]="reg" [filter]="true" [ngModelOptions]="{standalone: true}">  </p-dropdown>
    <button class="btn btn-primary" (click)="addRecipient(reg);">Add</button>

TS

addRecipient(reg: any){
    console.log(reg) //which return code not text.
}

How can I get the text or label also with code ?

Antikhippe
  • 6,316
  • 2
  • 28
  • 43
user630209
  • 1,123
  • 4
  • 42
  • 93

1 Answers1

1

How do you populate regionSelectList ?

If it looks like

this.regionSelectList = [{label:'Region A', value:'regionA'}, {label:'Region B', value:'regionB'}];

it should be ok : you'll get the value property in your addRecipient method.

See working Plunker

Antikhippe
  • 6,316
  • 2
  • 28
  • 43