在AngularDart中调用音频元素播放的正确方法是什么? 我知道我可以使用@ViewChild('audio')注释来获取ElementRef,但不推荐使用ElementRef。
<div class="audio-controls">
<material-fab raised (trigger)="onPlay()">
<material-icon icon="play_arrow" ></material-icon>
</material-fab>
</div>
<audio><source src="audio.ogg"></audio>
class AudioComponent {
void onPlay() {
//??
}
}
我刚开始学习AngualDart。我现在看到这是错误的做法。我应该使用AudioContext来播放音频,或者最后,作为最后的手段,在AudioComponent中创建AudioElement。 AudioElement不必添加到DOM树(?)。
模板应该用于定义接口而不是逻辑(音频标签)。