iknb/directives/wavesurfer.directive.js
2020-07-08 13:56:33 +02:00

23 lines
610 B
JavaScript

'use strict';
angular
.module('sloDialectsApp')
.directive('ngWavesurfer', function () {
return {
restrict: 'E',
link: function ($scope, $element, $attrs) {
$element.css('display', 'block');
var options = angular.extend({ container: $element[0] }, $attrs);
var wavesurfer = WaveSurfer.create(options);
if ($attrs.url) {
wavesurfer.load($attrs.url, $attrs.data || null);
}
$scope.$emit('wavesurferInit', wavesurfer);
}
};
});