Ram*_*a S 3 javascript typeahead angular
如何将Typeahead结果的数量限制为5或Angular 4中的某些内容?我在这里附上官方的plunker链接.我无法使用|limitTo
http://embed.plnkr.co/gV6kMSRlogjBKnh3JHU3/
这是模板
<section class="col-sm-12">
<div class="search-results style-3">
<input type="text" [value]="query"
ngxTypeahead
[taUrl]="url"
[taParams]="params"
(taSelected)="handleResultSelected($event)"
>
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
这是ts文件
export class AppComponent {
title = 'This is Angular TypeAhead v' + systemConfig.map['ngx-typeahead'].split('@')[1].split('/')[0];
public url = 'http://suggestqueries.google.com/complete/search';
public params = {
hl: 'en',
ds: 'yt',
xhr: 't',
client: 'youtube'
};
public query = '';
handleResultSelected (result) {
this.query = result;
}
generateWord() {
return chance.word();
}
}
Run Code Online (Sandbox Code Playgroud)
在Angular中,没有limitTo过滤器,它叫做SlicePipe.
使用| slice:0:3而不是limitTo
<input type="text" ngxTypeahead [value]="query3" [taList]="staticList | slice:0:3" (taSelected)="handleStaticResultSelected($event)">
Run Code Online (Sandbox Code Playgroud)
更新了plnkr:https://plnkr.co/edit/wqTHY2rHknXHF412BELQ ? p = preview
| 归档时间: |
|
| 查看次数: |
3008 次 |
| 最近记录: |