Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.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
Html 在键入3个字符后是否有方法触发select事件?_Html_Angular_Typescript_Button - Fatal编程技术网

Html 在键入3个字符后是否有方法触发select事件?

Html 在键入3个字符后是否有方法触发select事件?,html,angular,typescript,button,Html,Angular,Typescript,Button,我试图在用户在select输入中键入3个字符后触发一个事件,基本上我得到了一个服务,只有当select的文本框中有3个字符时,才会加载select的所有选项 我该怎么做 我的html: 可以这样做: customInput : Subject<string> = new Subject(); 现在,请收听本次活动: inputValueChanged(event){ this.customInput.next(event); } 您必须按以下方式订阅您的主题:

我试图在用户在select输入中键入3个字符后触发一个事件,基本上我得到了一个服务,只有当select的文本框中有3个字符时,才会加载select的所有选项

我该怎么做

我的html:

可以这样做:

customInput : Subject<string> = new Subject();
现在,请收听本次活动:

  inputValueChanged(event){
      this.customInput.next(event);
  }
您必须按以下方式订阅您的主题:

this.customInput.debounceTime(300).distinctUntilChanged().subscribe(value =>{
   //call your method if value.length >=3 
});

因此,仅当输入长度为
=3
时,才调用该ensignValues方法。为此,只需检查模型更改。但在得到结果后,您需要按用户键入的文本对其进行过滤,您可以创建自定义过滤管道

<fnd-extended-select label="Seleziona Insegna:" [autocomplete]="true"  [(ngModel)]="filter.ensign" (change)="changed($event)">
  <fnd-option *ngFor="let p of ensignValue?.ensign" [value]="p.id">{{p.description}}</fnd-option>
</fnd-extended-select>
  inputValueChanged(event){
      this.customInput.next(event);
  }
this.customInput.debounceTime(300).distinctUntilChanged().subscribe(value =>{
   //call your method if value.length >=3 
});
<fnd-extended-select label="Seleziona Insegna:" [autocomplete]="true"  [(ngModel)]="filter.ensign" (change)="changed($event)">
  <fnd-option *ngFor="let p of ensignValue?.ensign" [value]="p.id">{{p.description}}</fnd-option>
</fnd-extended-select>
changed(event) {
 if(this.filter.ensign.length >= 3) {
  this.ensignValues();
 }
}