Angular 如何获得角度(打字脚本)选择框';s选定的文本

Angular 如何获得角度(打字脚本)选择框';s选定的文本,angular,angular7,Angular,Angular7,如何在Angular(TypeScript)中的change函数中获取所选选项文本?如果使用默认选择html,可以尝试以下操作: 在youcomponent.html中: <select (change)="onChange($event.target.value)"> <option>Test1</option> <option>Test2</option> </select> 编辑:要控制文本而不是值,

如何在Angular(TypeScript)中的change函数中获取所选选项文本?

如果使用默认
选择html
,可以尝试以下操作: 在youcomponent.html中:

<select (change)="onChange($event.target.value)">
    <option>Test1</option>
    <option>Test2</option>
</select>
编辑:要控制文本而不是值,必须执行以下操作:

<select (change)="onChange($event)">
    <option [value]="1">Test1</option>
    <option [value]="2" >Test2</option>
</select>

请检查此项,如果我使用选项值此函数(onChange)返回值,我相信您会找到答案。但我需要文本。阅读我的编辑段落
<select (change)="onChange($event)">
    <option [value]="1">Test1</option>
    <option [value]="2" >Test2</option>
</select>
  onChange(event) {
    console.log(event.target.options[event.target.options.selectedIndex].text);
}