I've came across cordova RemoteControl plugin where, to listen to its event, the addEventListener is needed to be registered.
//listen for the event
document.addEventListener("remote-event", function(event) {
//do something
});
Is it a proper way for me to do it?
Try the below step to add event listener using angular 2. I am not sure about "remote-event" event but "click" event is working fine for me as given below.
import { ElementRef, Renderer } from '@angular/core';
constructor(public el: ElementRef, public renderer: Renderer) {
renderer.listenGlobal('document', 'click', (event) => {
// Do something with 'event'
});
}
As per comment below by @paqogomez.
Renderer
has been renamed to Renderer2
and listenGlobal
to listen
.
this works for me like magic
document.querySelector('#videostop').addEventListener('click', () => {
//function here
console.log('your result');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With