我做错了什么?我得到“EXCEPTION:模板解析错误:无法绑定到'ngValue',因为它不是已知的本机属性”
import {Component, Optional, Inject} from 'angular2/core';
@Component({
selector: 'm-Cities',
template: `
<select [(ngModel)]="selectedCity" style="margin-left: 30px; width:120px; height: 50px; padding-left: 50px;">
<option *ngFor="#city of cities" [ngValue]="city">{{city.name}}</option>
</select>
`,
providers: [],
directives: [],
pipes: []
})
export class Mcities{
selectedCity: Object;
cities: Object[] = [
{name: "SF"},
{name: "NYC"}
];
constructor() {}
}
答案 0 :(得分:3)
ngValue
。如果您使用的是旧版本,则会出现此错误。