2016-05-23 32 views
2

我做错了什么?我得到”EXCEPTION:模板解析错误:无法绑定到'ngValue',因为它不是知原生属性”无法绑定到'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() {} 

    } 

回答

3

ngValue在beta.14加入。如果您使用的是旧版本的这个错误是可以预期的。

+3

我使用RC3和它的工作不适合我 – Gab

相关问题