I am getting a weird error when trying to subscribe to an Observable.
Here is a watered down version of the code which presents the problem:
If you want to access it in ngOnInit
event then you would have to use { static: true }
property of ViewChild
something like this:
import { Component, ViewChild, ElementRef, OnInit } from '@angular/core';
import { Observable, fromEvent } from 'rxjs';
@Component({
template: ''
})
export class ActionOverviewDescription implements OnInit {
@ViewChild('input', { static: true }) button: ElementRef;
ngOnInit() {
let buttonStream$ = Observable.fromEvent(this.button.nativeElement, 'click')
.subscribe(res => console.log(res));
}
}