title: Call AngularJS from legacy code
body: <p>I'm using AngularJS to build HTML controls that interact with a legacy Flex application. All callbacks from the Flex app must be attached to the DOM window.</p>
  
  <p>For example (in AS3)</p>
  
  <pre><code>ExternalInterface.call("save", data);
  </code></pre>
  
  <p>Will call</p>
  
  <pre><code>window.save = function(data){
      // want to update a service 
      // or dispatch an event here...
  }
  </code></pre>
  
  <p>From within the JS resize function I'd like to dispatch an event that a controller can hear. It seems that creating a service is the way to go. Can you update a service from outside of AngularJS? Can a controller listen for events from a service? In one <a href="http://jsfiddle.net/6JvRV/" rel="nofollow noreferrer">experiment (click for fiddle)</a> I did it seems like I can access a service but updating the service's data doesn't get reflected in the view (in the example an <code>&lt;option&gt;</code> should be added to the <code>&lt;select&gt;</code>).</p>
  
  <p>Thanks!</p>