gpt4 book ai didi

javascript - 如何从 Angular 4的mbd-select中获取数据

转载 作者:行者123 更新时间:2023-11-30 20:47:32 28 4
gpt4 key购买 nike

我想使用表单从 HTML 模板中的 mdb-select 获取数据到组件 typescript 。我的 HTML 是:

<mdb-select [options]="optionsSelect" placeholder="Select Transaction" class="colorful-select dropdown-primary custom-input" (change)="getValue($event)"></mdb-select>

我的组件是:

optionsSelect: Array<any>;
this.optionsSelect = [
{ value: '1', label: 'Transaction 1' },
{ value: '2', label: 'Transaction 2' },
{ value: '3', label: 'Transaction 3' },
{ value: '4', label: 'Transaction 4' },
{ value: '5', label: 'Transaction 5' },
{ value: '6', label: 'Transaction 6' }
]

//get data of select from the html
getValue(event) {
console.log(event);
}

请建议我应该使用哪个事件将选项值从 mdb-select 获取到我的组件中。我已经使用(更改)事件处理程序,但它的工作方式不一样。

提前致谢。

最佳答案

使用选择的事件

<mdb-select [options]="optionsSelect" placeholder="Select Transaction" class="colorful-select dropdown-primary custom-input" (selected)="getValue($event)"></mdb-select>

关于javascript - 如何从 Angular 4的mbd-select中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48540537/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com