My goal is to include an audio
element inside a component. Initially, I approached this by using traditional methods:
$player: HTMLAudioElement;
...
ngOnInit() {
this.$player = document.getElementById('stream')
}
However, I wanted to follow The Angular Way™, so I decided to utilize @ViewChild
. The only drawback is that it returns an ElementRef
and requires accessing the nativeElement
property multiple times to interact with the element, which can become messy.
I envisioned doing something like this:
@ViewChild('stream') $player: HTMLAudioElement;
Unfortunately, this approach did not yield the expected results.