title: Call angular factory with pure javascript
body: <p>I struggled to title this question but basically I'm just starting off with angular and am using ngMaterial. I have a toast created by using an angular factory</p>
  
  <pre><code>app.factory('notify', ['$mdToast', '$animate', function($mdToast, $animate) {
      return {
          showToast: function(msg) {
               var toast = $mdToast.simple()
                    .content(msg)
                    .action('Close')
                    .highlightAction(false)
                    .position('top right');
              $mdToast.show(toast).then(function() {
                //
              });
          }
      }
  }]);
  </code></pre>
  
  <p>This works great if I have a button on the page that activates the toast however I have socket.io running as well with node monitoring redis for updates to pop up that notification. However I can't get it to work as I'm not quite sure how I can call that factory from within here</p>
  
  <pre><code>socket.on('notification.new', function (data) {        
      //call factory here to show toast
      console.log(data);
  });
  </code></pre>
  
  <p>I know if I have it on a controller I can do it by using</p>
  
  <pre><code>angular.element().scope().showToast(data)
  </code></pre>
  
  <p>But I don't want to create an element just to house the controller to call the function.</p>