Я хочу создать механизм публикации/подписки с системой событий angular.
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);
            });
      }
    }
})
если я устанавливаю HTML-документ таким образом, в консоли не появляется сообщение:
<div ng-app="app">
  <first></first>
  <second></second>
</div>
Если я меняю порядок первым и вторым, на сервере будет отображаться сообщение wirite.
<div ng-app="app">
  <second></second>
  <first></first>
</div>
Но мне нужна первая директива или внутренняя директива.
<div ng-app="app">
  <first></first>
  <second></second>
</div>
<div ng-app="app">
  <first>
      <second></second>
  </first>
</div>
Я пробовал как $rootScope.$broadcast, так и $rootScope.$emit, но не смотрел.
