title: Accessing $dom from an $on event declared inside a directive
body: <p>I made a directive, has a template, and inside the link, I have an event handler using <code>scope.$on</code></p>
  
  <pre><code>angular.module('app').directive('navPills', function() {
     return {
        restrict: 'E',
        templateUrl: '/partials/nav-pills.html',
        link: function(scope, element) {
            scope.$on('focusChanged', function(event, elemFocused) {
               // check if the focused item is part of the directive
               if (element.find(elemFocused).length &gt; 0) { 
                  // do something
               }
            });
        }
     }
  });
  </code></pre>
  
  <p>When running this code, I run into errors when <code>focusChanged</code> is emitted.  It's because element is undefined within the event handler.  </p>
  
  <p>My question is, what is the solution around this?</p>