user1906451
user1906451

Reputation: 83

Angular application notify surrounding JQuery app of an event

I have an angular 1.5 app on a page surrounded by a jQuery application. I want to notify the surrounding page or jQuery application that an event has occurred in the AngularJS app i.e validation issue. How can i do this?

Upvotes: 0

Views: 34

Answers (1)

Mohsin Muzawar
Mohsin Muzawar

Reputation: 1212

// Add an event listener

document.addEventListener("name-of-event", function(e) {
  console.log(e.detail); // Prints "Example of an event"
});

// Create the event

var event = new CustomEvent("name-of-event", { "detail": "Example of an event" });

// Dispatch/Trigger/Fire the event

document.dispatchEvent(event);

Upvotes: 1

Related Questions