How can you created an event emitter that is only triggered once and self-destructs after that. An equivalent to jQuery's .one() function?
You actually have one() available to you in AngularJS via the jqLite library. jsLite is an abridged version of jQuery that is the minimum needed to power Angular.
https://docs.angularjs.org/api/ng/function/angular.element
var e = angular.element(document.querySelector('.myDivClass'));
e.one('click', function(){
alert("Only works once!");
});
Example on Codepen
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