如何在警报窗口中显示从列表中选择的项目的名称


每次用户从列表中选择月份时,我都会尝试显示月份名称。我设法显示了一个警报,但我想知道如何显示所选月份或所选月份的名称。我的意思是,当用户选择一个月时,下面的文本应该出现在的例子中
month choosen is April

请让我知道如何实现

app.component.html

<div> Months :
<select (change) = "changemonths($event)">
<option *ngFor="let i of months">{{i}}</option>
</select>
</div>

应用程序组件.ts

months = ["Jan", "Feb", "Mar", "April", "May", "Jun",
"July", "Aug", "Sept", "Oct", "Nov", "Dec"];

changemonths(event) {
alert("Changed month from the Dropdown" + event.value);
console.log(event);
}

使用event.target.value而不是event.value

changemonths(event) {
alert("Changed month from the Dropdown" + event.target.value);
console.log(event);
}

演示:https://stackblitz.com/edit/angular-ivy-hzdewq?file=src/app/app.component.ts

警报("更改月份"+event.target.value(;

最新更新