2016-05-26 5 views
0

Screenshot des Fehlers nicht inbegriffen: enter image description hereRouten Generator für 'item' wurde in Parameter Fehler

Plunker (derzeit nicht funktioniert): plnkr.co/edit/ft9Z4mq8C1llpAxA0Z1v?p=catalogue

Link zu Voll Projekt: https://www.dropbox.com/s/0579y250pq5eti5/Project33.zip?dl=0

Voll Code von wiki.component.ts (Code der Seite, die Fehler verursacht):

import { Component }  from 'angular2/core'; 
import { JSONP_PROVIDERS } from 'angular2/http'; 
import { Observable }  from 'rxjs'; 
import { WikipediaService } from './wikipedia.service'; 
import {Router, RouteParams, RouterLink, ROUTER_DIRECTIVES} from 'angular2/router'; 

@Component({ 
    selector: 'Wikithing', 
    template: ` 
    <h1>Search and Display Page</h1> 
    <p><i>Fetches after each keystroke</i></p> 
    <input #term (keyup)="search(term.value)"/> 
    <ul> 
    <li *ngFor="#item of items | async">{{item}} <br> <p> 

    </p> Price (in USD): $ {{item.price}} <br> <p> 

     </p> Availability: 24 hours <br> <p> 

     </p> Quantity currently in stock: {{quantity}} 

     <br> <p> 

     </p> Image of item: <img src="http://weknowyourdreamz.com/images/apple/apple-05.jpg" alt="Apple" style="width:100px;height:100px;"> 
     <br> <p> 
     </p> 
       <p> 

      </p> 

      <a [routerLink]="['BiddingPage']">Click here to bid on this item.</a> 
      <button (click)="gotoItem(item)">Click here to bid on this item.</button> 
      <p> 

       </p> 
     <br> <p> 
     </li> 
    </ul> 
    `, 
    providers:[JSONP_PROVIDERS, WikipediaService], 
    directives: [ROUTER_DIRECTIVES, RouterLink], 

}) 
export class WikiComponent { 
    constructor (private wikipediaService: WikipediaService, private router:Router) {} 
    items: Observable<string[]>; 
    // item: Item[] = []; 



    search (item: string) { 
    this.items = this.wikipediaService.search(item); 
    this.items.map((items) => items.map(() => ({ 
     name: items, 
     prices: Math.random(), 
     quantity: Math.random(), 
     availability: Math.random() 
    }))); 

    var Prices = Math.random() + Math.random(); 
    var quantity = Math.random(); 
    } 
    gotoItem (item: any) { 
    this.router.navigate(['BiddingPage', {item: item}]); 
    } 
} 

Weitere Informationen und den Kontext des Problems:

stackoverflow.com/questions/37422205/displaying-data-that-is-consistent-with-search-results-on-a-different-webpage-t

Antwort

2

Haftungsausschluss: Mein Englisch kann schlecht sein, sorry: c.

das, weil in Ihrem @RouteConfig Sie haben declarated ist, dass Sie einen Artikel parametter wie diese brauchen:

{path: '/BiddingPage/:item', name: 'BiddingPage', component: BiddingPageComponent}, 

Und in der Vorlage nicht Sie, dass parametter haben:

<a [routerLink]="['BiddingPage']">Click here to bid on this item.</a>//the "item" is missing 

Ihre Vorlage sollte so sein:

<a [routerLink]="['BiddingPage',{item:item}]">Click here to bid on this item.</a> 

Genießen.