1
나는 지금 내가 그것을 여기 angular4의 드롭 다운 값을 설정하는 방법은 무엇입니까?
내 코드
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>