Getting Error "Clicked NaN times". What is the correct way to execute Rxjs code below?
import { Component, ViewChild, ElementRef } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromEvent';
import 'rxjs/add/operator/scan';
import 'rxjs/add/operator/throttleTime';
export class AppComponent {
count: number;
title = 'app';
@ViewChild('input') button: ElementRef;
// @ViewChild('input1') button: ElementRef;
constructor() {
}
ngAfterViewInit() {
Observable.fromEvent(this.button.nativeElement, 'click')
.throttleTime(1000)
.scan(count => this.count + 1, 0)
.subscribe(count => console.log(`Clicked ${count} times`));
}
}