Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 处理音频标签上的404错误_Html_Angular_Typescript - Fatal编程技术网

Html 处理音频标签上的404错误

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]="

我有一个带有typscript的Angular2应用程序。我有一个音频标签,它以
@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>