Html 处理音频标签上的404错误
我有一个带有typscript的Angular2应用程序。我有一个音频标签,它以Html 处理音频标签上的404错误,html,angular,typescript,Html,Angular,Typescript,我有一个带有typscript的Angular2应用程序。我有一个音频标签,它以@Input的形式接收其文件,我想在路径中不存在该文件时生成一个异常: html是: <div> <audio controls autoplay id="audio" (error)="audioError()"> <!--source src="horse.ogg" type="audio/ogg"--> <source [src]="
@Input
的形式接收其文件,我想在路径中不存在该文件时生成一个异常:
html是:
<div>
<audio controls autoplay id="audio" (error)="audioError()">
<!--source src="horse.ogg" type="audio/ogg"-->
<source [src]="fileToPlay" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div>
我尝试使用onerror
,但它不起作用。使用(错误)
而不是onerror
(用偏执围绕事件)
您的浏览器不支持音频元素。
仍然不起作用。我更新了我的问题@潘卡吉公园酒店
export class PlayComponent implements OnChanges {
@Input() fileToPlay:string;
audioError(){
console.log('out of range');
}
}
<audio controls autoplay id="audio" (error)="audioError()">
<!--source src="horse.ogg" type="audio/ogg"-->
<source [src]="fileToPlay" type="audio/mpeg">
Your browser does not support the audio element.
</audio>