如何解决如何在angular的keyup='keyUp.next$ event'中添加更多两个参数并使其在ts中可访问
这是HTML标记: 在按键事件中需要传递两个参数。
<div>
<input type="text" (keyup)='keyUp.next($event,field)'>
</div>
TS:如何获取要在TS代码中使用的第二个参数 field 。
ngOnInit() {
fromEvent(this.movieSearchInput.nativeElement,'keyup').pipe(
// get value
map((event: any) => {
return event.target.value;
})
// if character length greater then 2,filter(res => res.length > 2)
// Time in milliseconds between key events,debounceTime(1000)
// If previous query is diffent from current,distinctUntilChanged()
// subscription for response
).subscribe((text: string) => {
this.isSearching = true;
this.searchGetCall(text).subscribe((res) => {
console.log('res',res);
this.isSearching = false;
this.apiResponse = res.data;
},(err) => {
this.isSearching = false;
console.log('error',err);
});
});
}
如何使用ts代码访问参数
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。