答案 0 :(得分:1)
在Firefox上看起来像选择双向数据绑定,我尝试使用Angular2文档中的示例: https://angular.io/resources/live-examples/forms/ts/plnkr.html它与您的问题相同。
在修复错误之前,您可以使用更旧的时尚代码替换,例如:
import {Component} from 'angular2/core'
@Component({
selector: 'my-app',
template: `
<select (change)="selectPart($event)">
<option *ngFor="#part of parts" [value]="part.code">{{part.name}}</option>
</select>
<select (change)="selectLevel($event)">
<option *ngFor="#level of levels" [value]="level.code">{{level.name}}</option>
</select>
{{product|json}}
`
})
export class App {
product = { partCode: 'aa', levelCode: 'lv1' };
parts = [
{ code: 'aa', name: 'AA' },
{ code: 'bb', name: 'BB' }
];
levels = [
{ code: 'lv1', name: 'Level 1' },
{ code: 'lv2', name: 'Level 2' }
];
selectPart($event) {
this.product.partCode = $event.target.value;
}
selectLevel($event) {
this.product.levelCode = $event.target.value;
}
}
更新了plunker:http://plnkr.co/edit/4cHCyBrSI932LOKKcxEN?p=preview