In my p-dropdown
, I am trying to extract the selected value.
<p-dropdown optionLabel="name" [options]="things"
placeholder="Select Thing" [(ngModel)]="input" (onChange)="getValue(input)"></p-dropdown>
typescript:
//each line prints the same thing of [object Object].
getValue(changedValue){
console.log(changedValue);
console.log(this.input);
console.log(this.input.valueOf());
}
I have also experimented with using (ngModelChange)
instead of (onChange)
and attempting $event
, $event.target.value
, $event.value
as parameters for getValue
in my html. However, the console consistently displays [object Object]
.
The reason behind my quest to retrieve the actual value is that I require it to populate another dropdown list. The value I'm attempting to retrieve serves as a search keyword to populate the new dropdown. Unfortunately, this search keeps resulting in undefined
.