title: Resolve promise with an object with a "then" function
body: <p>This is a bit of an abstract question, as I don't have a particular use-case right now. I've noticed that if you resolve a promise with a promise</p>
  
  <pre><code>var deferredA = $q.defer();
  var deferredB = $q.defer();
  deferredA.promise.then(function(result) {
    // Will get here once promiseB has been resolved.
  });
  deferredA.resolve(deferredB.promise);
  </code></pre>
  
  <p>than promiseA isn't actually resolved until promiseB has been resolved (and then promiseA is resolved with the value of promiseB's resolution). However, what if I wanted to resolve with a value of an object with a "then" function, as:</p>
  
  <pre><code>var deferred = $q.defer();
  deferred.promise.then(function(result) {
    // Aim is to get here with result = {then:function(){}},
    // as though I had resolved a promise with a non-promise value,
    // but this function is never called
  });
  deferred.resolve({
    then: function() {
    }
  });
  </code></pre>
  
  <p>then promiseA never actually gets resolved, as it assumed that the value is a promise, even though in the above example it's not, as in, it wasn't created with $q.defer(). There is an example plunkr at </p>
  
  <p><a href="http://plnkr.co/edit/Z8XUKzxHtGBKBmgPed2q?p=preview" rel="nofollow">http://plnkr.co/edit/Z8XUKzxHtGBKBmgPed2q?p=preview</a></p>
  
  <p>Is there a way around this? If so, how?</p>
  
  <p><strong>Edit</strong>: clarified deferred/promise &amp; put in example "then" callbacks.</p>