Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 如何使搜索栏仅在搜索字段中有3个以上字符时才启用_Ionic Framework - Fatal编程技术网

Ionic framework 如何使搜索栏仅在搜索字段中有3个以上字符时才启用

Ionic framework 如何使搜索栏仅在搜索字段中有3个以上字符时才启用,ionic-framework,Ionic Framework,这是我的搜索栏,当我们输入任何输入,但不是单个字符时,它开始搜索其值。我想定制这个(输入)=getItems($event),这样它只在输入超过3个字符时工作 <ion-searchbar (ionInput)="getItems($event)"></ion-searchbar> <ion-list *ngFor="let product of products" > <ion-item text-wrap (click)="openProduc

这是我的搜索栏,当我们输入任何输入,但不是单个字符时,它开始搜索其值。我想定制这个(输入)=getItems($event),这样它只在输入超过3个字符时工作

 <ion-searchbar (ionInput)="getItems($event)"></ion-searchbar>
 <ion-list *ngFor="let product of products" >
<ion-item text-wrap  (click)="openProductPage(product.id,product.name)">
     <h2> {{ product.name }} </h2>     
</ion-item>
 </ion-list>

{{product.name}

如果您只是不想激活搜索过程,那么下面的代码就足够了

getItems(event){
  if(!event.target.value || event.target.value.length < 3){
     return;
  }
  // search 
}
getItems(事件){
如果(!event.target.value | event.target.value.length<3){
返回;
}
//搜寻
}