将选择元素绑定到角度上的对象
@Component({ selector: 'myApp', template: `<h1>My Application</h1> <select [(ngModel)]="selectedValue"> <option *ngFor="#c of countries" value="c.id">{{c.name}}</option> </select>`})export class AppComponent{ countries = [ {id: 1, name: "United States"}, {id: 2, name: "Australia"} {id: 3, name: "Canada"}, {id: 4, name: "Brazil"}, {id: 5, name: "England"} ]; selectedValue = null;}
<option *ngFor="#c of countries" value="c">{{c.name}}</option>
倚天杖
慕慕森