JSFiddle - React, Tailwind, and code Playground

by Amal Das

HTML

<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js"></script>
<div ng-app="sathya">
  <div ng-controller="ParentCtrl">
    

    <button ng-click="go()">Button </button>
    <div ng-controller="SiblingCtrl"><button ng-click="back()">back </button>
    </div>
  </div>
</div>

JavaScript

var app = angular.module('sathya', []);

app.controller('ParentCtrl',
  function ParentCtrl($scope) {
    console.log("this is parent");
    // going down!

    $scope.go = function() {
      $scope.$broadcast('parent', 'Sathyalog')

    }
    $scope.$on('ccc', function(event, data) {
         $scope.abc=data;
         alert($scope.abc);
    });
  });

app.controller('SiblingCtrl',
  function SiblingCtrl($scope) {
    console.log("this is child");
    
    $scope.$on('parent', function(event, data) {
      console.log(data); // My broad cast message
    });
        $scope.back = function() {
      $scope.$emit('ccc', [1, 2, 3]);


    }
  });