title: Promise callback not called in Angular JS
body: <p>If I call <code>connect</code> from <code>doStuff</code>, I get the message that <em>"the socket is connected"</em>, but the <code>callback</code> is not called. What am I missing here? </p>
  
  <pre><code> $scope.connect = function() {
      var defer = $q.defer();
      ws = new WebSocket("ws://server.com:port");
      ws.onopen = function(){  
          console.log("Socket connected");
          defer.resolve("socket connected");
      };
      return defer.promise;
  }
  
  $scope.doStuff = function() {
      $scope.connect().then(function(data) {
          console.log("And we're off!", data);
      });
  }
  </code></pre>