I'm trying to get an audio
element inside a component. At first I was doing it the old fashioned way:
$player: HTMLAudioElement;
...
ngOnInit() {
this.$player = document.getElementById('stream')
}
But I wanted to do it The Angular Way™ so I figured I should use @ViewChild
. But it returns an ElementRef
and I have to repeatedly drill into the nativeElement
property to actually act on the element and it just seems messier.
I would like to do something like this:
@ViewChild('stream') $player: HTMLAudioElement;
But that doesn't work.