JSFiddle - React, Tailwind, and code Playground

by barteloma

HTML

<div ng-app="app">
  <first></first>
  <second></second>
</div>

JavaScript

angular.module("app",[]);

angular.module("app").directive("first", function($rootScope){
		return {
    	template: "First Directive",
      link:function(scope,element,attribute){
      		   $rootScope.$broadcast("OnFirstDirectiveCreated", {
                "message": "I'm first directive"
            });
      }
    }
})

angular.module("app").directive("second", function($rootScope){
		return {
    	template: "Second Directive",
      link:function(scope,element,attribute){
      		var handler = $rootScope.$on("OnFirstDirectiveCreated", 
           		function (event, args) {
                console.log("First Directive Message: " + args.message);
           });
      }
    }
})