我正在制作一个ebay克隆网站,该网站通过维基百科搜索结果制作拍卖/竞标系统。
搜索结果的屏幕截图:first screenshot
不同网页的屏幕截图(此屏幕截图中的“Apple”应改为“A”):second screenshot
我正在努力使这个变量保持一致:
尝试获取{{item.name}}时出错的屏幕截图:dropbox.com/s/wlcovvt8x5v7cne/screenthis.png?dl=0
导致错误的biddingpage.component.html
代码:
<label for="name">Name of item: {{item.name}} </label>
<p>
</p>
链接到完整项目:dropbox.com/s/84svnggv8xeub5m/FullProjectEbayClone.zip?dl=0
我要更改的代码文件的名称:
wiki.component.ts
biddingpage.component.html
biddingpage.component.ts
链接到完整项目的plunker(目前无效):plnkr.co/edit/1lcI4dURHwA8D9IQtqSf?p=info
wiki.component.ts代码:
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>
<p>
</p>
<br> <p>
</li>
</ul>
`,
providers:[JSONP_PROVIDERS, WikipediaService],
directives: [ROUTER_DIRECTIVES, RouterLink],
})
export class WikiComponent {
constructor (private wikipediaService: WikipediaService) {}
items: Observable<string[]>;
search (term: string) {
this.items = this.wikipediaService.search(term);
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();
}
}