title: Notify AngularJS Controller about events from outside
body: <p>New to Angular so I apologize if the question is silly.</p>
  
  <p>So I'm making an app and one part of it is outside of Angular's "scope" so to speak and this part is responsible for receiving incoming messages (xmpp)</p>
  
  <p>And then there is that Angular controller that has to be notified about incoming messages. What I did is an ugly work around but it works:</p>
  
  <p><strong>view.html:</strong></p>
  
  <pre><code>&lt;button ng-click="refreshLayout()" id="refreshLayoutButton" style="display:none"&gt;&lt;/button&gt;
  </code></pre>
  
  <p><strong>controllers.js:</strong></p>
  
  <pre><code>.controller('chatCtrl', function($scope) {
       $scope.refreshLayout = function() { ... }
  })
  </code></pre>
  
  <p><strong>outside.js:</strong></p>
  
  <pre><code>if(incomingMessage) {
       $("#refreshLayoutButton").click();
       // append the message to view.html
  }
  </code></pre>
  
  <p>Is there anyway to exclude jQuery? I want to send the message from outside.js to chatCtrl and then send it to view.html</p>
  
  <p>OR</p>
  
  <p>just notify about the event so it could invoke $scope.refreshLayout (techincally I can append incoming messages directly to view.html using jQuery without Angular, but the first option is still more preferable)</p>