2015-05-04 19 views
5

我試圖用AngualarJsAngularJS錯誤,而使用ngAudio

播放音頻我的HTML代碼:

<!doctype HTML> 
<html> 
<head> 
</head> 
<body ng-app="test" ng-controller="audioTest"> 
    <button ng-click="playSound()"></button> 
    <script src="javascripts/angular.min.js"></script> 
    <script  src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> 
    <script src="javascripts/angular.audio.js"></script> 
    <script src="app.js"></script> 

</body> 
</html> 

我app.js代碼:

var app = angular.module("test",['ngAudio']); 

var audio = app.controller("audioTest",function($scope,ngAudio){ 
$scope.playSound = function(){ 
    $scope.audio = ngAudio.load("abc.wav"); 
    $scope.audio.play(); 
} 
}); 

雖然我加載頁面我得到在控制檯,導致我錯誤 Error Details

+0

確保你的腳本路線'的JavaScript/NG-audio.min.js'是真正解決的腳本 – Cyberdelphos

+0

我有也嘗試從http://danielstern.github.io/ngAudio/#/ –

+0

替換腳本正確的腳本名稱似乎是「angular.audio.js」而不是「ng-audio.min.js」 – Cyberdelphos

回答

2

您錯誤重新移植是由於錯誤解決angular.audio.js腳本不能由名稱javascripts/angular.audio.js

我做了一個工作小提琴發現:http://jsfiddle.net/en8x1nny/

這撥弄會導入the original demo from ngAudio是使用腳本。

該腳本的完整路徑爲:http://danielstern.github.io/ngAudio/angular.audio.js

您可以將其下載並添加到javascripts目錄中。請不要在上面提到的URL中使用它,因爲github不是用於提供腳本的CDN。

如果以前通過涼亭安裝ngAudio,腳本應該是:

your_project_path/bower_components/angular-audio/app/angular.audio.js