【发布时间】:2019-01-02 08:37:14
【问题描述】:
我有一个p-dropdown,我想在其中获取被选中的值。
<p-dropdown optionLabel="name" [options]="things"
placeholder="Select Thing" [(ngModel)]="input" (onChange)="getValue(input)"></p-dropdown>
打字稿:
//each line prints the same thing of [object Object].
getValue(changedValue){
console.log(changedValue);
console.log(this.input);
console.log(this.input.valueOf());
}
我也尝试过使用(ngModelChange) 代替(onChange) 以及尝试$event、$event.target.value、$event.value 在我的html 中将参数设置为getValue。控制台总是打印[object Object]。
我想要查看实际值的动机是我需要该值来填充另一个下拉列表。我使用我试图查看的这个值作为实际填充另一个下拉列表的搜索值。此搜索不断返回undefined。
【问题讨论】:
-
你的东西是什么样子的?
-
@fastAsTortoise 它是一个
Thing类型的数组,具有三个字段number, string, and number。我知道这个数组things已正确填充,因为这是我首先填充下拉列表的options的方式。
标签: angular typescript primeng