【发布时间】:2016-05-12 20:28:15
【问题描述】:
我基本上是在尝试创建一个搜索栏,搜索数据然后显示该数据(通过基于单击按钮后搜索框输入的过滤器)(来自维基百科或只是本地假数据,它没有没关系)
此错误已在另一个问题中多次发布,但解决方案的上下文差异太大,无法帮助我。
这是错误的截图:
这是完整的项目(没有nodes_modules文件夹):
https://www.dropbox.com/s/kxq1qgfhh8huudz/FullProject.zip?dl=0
有错误的代码 (wiki.component.ts):
import { Component } from 'angular2/core';
import { JSONP_PROVIDERS } from 'angular2/http';
import { Observable } from 'rxjs/Observable';
import { WikipediaService } from './wikipedia.service';
@Component({
selector: 'Wikithing',
template: `
<h1>Wikipedia Demo</h1>
<p><i>Fetches after each keystroke</i></p>
<input #term (keyup)="search(term.value)"/>
<ul>
<li *ngFor="let item of items | async">{{item}}</li>
</ul>
`,
providers:[JSONP_PROVIDERS, WikipediaService]
})
export class WikiComponent {
constructor (private wikipediaService: WikipediaService) {}
items: Observable<string[]>;
search (term: string) {
this.items = this.wikipediaService.search(term);
}
}
文本格式错误:
Failed to load resource: the server responded with a status of 404 (Not Found)
angular2.dev.js:384 Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
angular2.dev.js:23935 EXCEPTION: Error: Uncaught (in promise): Template parse errors:
Parser Error: Unexpected token | at column 25 in [ngFor let item of items | async] in WikiComponent@5:10 ("
<input #term (keyup)="search(term.value)"/>
<ul>
<li [ERROR ->]*ngFor="let item of items | async">{{item}}</li>
</ul>
"): WikiComponent@5:10
【问题讨论】:
标签: javascript html angular