Nothing happens with following codes. Anyone can help me how to use rxjs's fromEvent in native-angular?
@ViewChild('skipBtn') public skipBtn:ElementRef;
...
ngAfterViewInit(): void {
fromEvent(this.skipBtn.nativeElement, 'click').subscribe(()=>{
dialogs.alert('skipBtn click').then();
});
}
Hi @wanpeng2008,
I reviewed the code sample, and I am assuming that you are trying to add event listener via fromEvent to the button. If this is the case, you should change 'click' with 'tap'. For example:
fromEvent(this.skipBtn.nativeElement, 'tap').subscribe(()=>{
dialogs.alert('skipBtn click').then();
});
Ths NativeScript button does not have click event, and if you use the code attached in your comment, nothing will happen, when you click on the button. Also for further questions, please use our forum or StackOverflow thread
Hi @tsonevn,
Thanks for your help in correcting my mistake.