Angular Mat自动完成未侦听滚动事件
我试图在mat autocomplete上添加一个滚动事件,但它没有触发此事件Angular Mat自动完成未侦听滚动事件,angular,angular-material,angular-material2,Angular,Angular Material,Angular Material2,我试图在mat autocomplete上添加一个滚动事件,但它没有触发此事件 <input matInput [formControl]="myControl" [matAutocomplete]="auto" name="myControl" #input /> <mat-autocomplete #auto="matAutocomplete"
<input
matInput
[formControl]="myControl"
[matAutocomplete]="auto"
name="myControl"
#input
/>
<mat-autocomplete #auto="matAutocomplete" cdkScrollable>
<mat-option
*ngFor="let option of filteredOptions"
[value]="option"
>
{{ option }}
</mat-option>
</mat-autocomplete>
constructor(public scroll: ScrollDispatcher, private ngZone: NgZone) {
}
ngAfterViewInit() {
fromEvent(this.input.nativeElement, 'input')
.pipe(map((event: Event) => (event.target as HTMLInputElement).value))
.pipe(debounceTime(1000))
.pipe(distinctUntilChanged())
.subscribe(data => this.getData());
this.scroll.scrolled().subscribe((data: CdkScrollable) => {
console.log(data);
});
this.ngZone.run(() => {
console.log('to run change detection');
})
}
{{option}}
构造函数(公共滚动:ScrollDispatcher,私有ngZone:ngZone){
}
ngAfterViewInit(){
fromEvent(this.input.nativeElement,'input')
.pipe(映射((事件:事件)=>(event.target作为HTMLInputElement.value))
.管道(去BounceTime(1000))
.pipe(distinctUntilChanged())
.subscribe(data=>this.getData());
this.scroll.scrolled().subscribe((数据:CdkScrollable)=>{
控制台日志(数据);
});
此.ngZone.run(()=>{
log('运行更改检测');
})
}
我已经试过了,但是不起作用
请帮帮我