I'm trying to get a native javascript event listener inside an AngularJs controller. I don't try to explain why but I cant' understand how to solve this.
I've created the custom event like this:
var event = document.createEvent('HTMLEvents');
event.initEvent('custom-event', true, true);
document.dispatchEvent(event);
and inside the angular controller:
angular.module('uploadCtrl', [])
.controller('uploadController', ['$scope', '$window', '$compile', function($scope, $window, $compile, $http, Video) {
document.addEventListener('custom-event', function(e) {
console.log('event received');
})
}]);
What I'm doing wrong? Thanks