【发布时间】:2019-10-30 04:28:46
【问题描述】:
我有 2 个下拉菜单,我需要在单击 angular 6 或 typescript 中的保存按钮时获取这些下拉菜单的选定值。我在 jquery 中知道,但在这里我是 angular 6 的新手,谁能帮帮我。下面是代码
app.component.html
<select class="select1">
<option>country1</option>
<option>country2</option>
<option>country3</option>
</select>
<select class="select2">
<option>state1</option>
<option>state2</option>
<option>state3</option>
</select>
<button (click)="save()">save</button>
app.component.ts
declare var require: any;
import { Component,OnInit, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{
toggle:boolean = true;
click : any;
selectOneVal : any;
selectTwoVal : any;
ngOnInit(){
}
save(){
console.log(this.selectOneVal);
console.log(this.selectTwoVal)
}
}
【问题讨论】:
标签: html typescript angular6