怎样才能将预先输入的结果限制为5或4角左右的数字?我已经在这里附上了官方的柱塞链接。我不能使用|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>这是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();
}
}发布于 2018-02-11 05:27:10
在角度上,没有limitTo滤波器,它称为SlicePipe。
使用| slice:0:3而不是limitTo
<input type="text" ngxTypeahead [value]="query3" [taList]="staticList | slice:0:3" (taSelected)="handleStaticResultSelected($event)">更新的plnkr:https://plnkr.co/edit/wqTHY2rHknXHF412BELQ?p=preview
https://stackoverflow.com/questions/48728304
复制相似问题