1
私はいくつかの値を渡しています、今私は、ドロップダウンの選択を設定したい、どのように私はそれを行うことができ、ここでangle4のドロップダウン値を設定する方法は?
は私のコード
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
dataset: any[] = [
{ value: 'one', key: 1 },
{ value: 'two', key: 2 },
{ value: 'three', key: 3 },
{ value: 'four', key: 4 }
]
selectionChanged(data) {
debugger;
}
}
HTML
であるためにドロップダウンを持っています<div>
<select (change)="selectionChanged($event.target.value)">
<option *ngFor="let item of dataset;let i=index " [value]="item.key" >{{item.value}}</option>
</select>
</div>