2016-11-27 72 views
0

錯誤實現一個下拉部件的屬性綁定按照SO question這是結合下拉值(選擇信息)與以下設置?:角2下拉分量問題

的.html到product.categoryId正確的方式

<div *ngIf="product"> 
    <h2>{{product.name}}</h2> 
    <div> 
     <label>Id: </label>{{product.productId}} 
    </div> 
    <div> 
     <label>Name: </label> 
     <input [(ngModel)]="product.name" placeholder="name" /> 
    </div> 
    <div> 
     <label>Price: </label> 
     <input [(ngModel)]="product.price" placeholder="price" /> 
    </div> 
    <div> 
     <label>Image name: </label> 
     <input [(ngModel)]="product.imageName" placeholder="imageName" /> 
    </div> 
    <div> 
     <label>Thumb image name: </label> 
     <input [(ngModel)]="product.thumbImageName" placeholder="thumbImageName" /> 
    </div> 
    <dropdown [values]="dropdownValues" (select)="action($event.value)"></dropdown> 
    <div> 
     <label>Category Id: </label> 
     <!-->input [(ngModel)]="product.categoryId" placeholder="categoryId" /--> 
    <!--Trying to bind this property with selectItem from DropdownComponent/--> 
     {{product.categoryId}} 
    </div> 

    <button (click)="goBack()">Back</button> 
    <button (click)="save()">Save</button> 
</div> 

錯誤的瀏覽器

zone.js:388Unhandled Promise rejection: Template parse errors: 
Can't bind to 'values' since it isn't a known property of 'dropdown'. ("    {{product.price}} 
       {{product.categoryName}} 
       <dropdown [ERROR ->][values]="dropdownValues" (select)="action($event.value)"></dropdown> 
       {{product.thum"): [email protected]:26 
'dropdown' is not a known element: 
1. If 'dropdown' is an Angular component, then verify that it is part of this module. 
2. If 'dropdown' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. (" 
       {{product.price}} 
       {{product.categoryName}} 
       [ERROR ->]<dropdown [values]="dropdownValues" (select)="action($event.value)"></dropdown> 
       {{pr"): [email protected]:16 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:(…) Error: Template parse errors: 
Can't bind to 'values' since it isn't a known property of 'dropdown'. ("    {{product.price}} 
       {{product.categoryName}} 
       <dropdown [ERROR ->][values]="dropdownValues" (select)="action($event.value)"></dropdown> 
       {{product.thum"): [email protected]:26 
'dropdown' is not a known element: 
1. If 'dropdown' is an Angular component, then verify that it is part of this module. 
2. If 'dropdown' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. (" 
       {{product.price}} 
       {{product.categoryName}} 
       [ERROR ->]<dropdown [values]="dropdownValues" (select)="action($event.value)"></dropdown> 
       {{pr"): [email protected]:16 
    at TemplateParser.parse (http://localhost:18678/dist/app.bundle.js:20029:19) 
    at RuntimeCompiler._compileTemplate (http://localhost:18678/dist/app.bundle.js:43294:51) 
    at http://localhost:18678/dist/app.bundle.js:43214:62 
    at Set.forEach (native) 
    at RuntimeCompiler._compileComponents (http://localhost:18678/dist/app.bundle.js:43214:19) 
    at createResult (http://localhost:18678/dist/app.bundle.js:43110:19) 
    at ZoneDelegate.invoke (http://localhost:18678/dist/app.bundle.js:92363:26) 
    at Zone.run (http://localhost:18678/dist/app.bundle.js:92245:43) 
    at http://localhost:18678/dist/app.bundle.js:92633:57 
    at ZoneDelegate.invokeTask (http://localhost:18678/dist/app.bundle.js:92396:35) 
    at Zone.runTask (http://localhost:18678/dist/app.bundle.js:92285:47) 
    at drainMicroTaskQueue (http://localhost:18678/dist/app.bundle.js:92532:35) 
+0

是的,這是正確的。 –

回答

0

都不可能是你的問題,因爲你不導入這個組件到模塊的地方用來。您收到的錯誤信息正是我忽略導入時得到的錯誤信息。