Nativescript-angular: how to use rxjs fromEvent in nativescript-angular

Created on 28 Jun 2018  路  2Comments  路  Source: NativeScript/nativescript-angular

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(); }); }

question

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manojdcoder picture manojdcoder  路  3Comments

Sulman633 picture Sulman633  路  3Comments

bhavincb picture bhavincb  路  3Comments

vakrilov picture vakrilov  路  3Comments

tsonevn picture tsonevn  路  3Comments