title: AngularJS : $q -> deferred API order of things (lifecycle) AND who invokes digest?
body: <p>The <a href="https://docs.angularjs.org/api/ng/service/%24q" rel="nofollow">$q service</a> is very powerful in angularjs and make our life easier with asynchronous code. </p>
  
  <p>I am new to angular but using deferred API is not very new to me. I must say that I completely ok with the <code>How to use</code> part of documentation + there are very useful links for that within the docs + I checked out the source either. </p>
  
  <p>My question is more about the <strong>under the hood</strong> parts of deferred and promise API objects in angular. What are the exact <strong>phases</strong> in their <strong>life cycles</strong> and how are they interacts with <code>rootScope.Scope</code>(s). My assumptions are that when the promise resolves - it invokes the digest loop ??? yes / no ?</p>
  
  <p>Can one provide a detailed answer with specific respect to the following list of aspects:</p>
  
  <ol>
  <li>What is the order of things that happen in each of your described
  steps / phases</li>
  <li>When new deferred object with a new promise instance created - who aware of it / is it 
  important ?</li>
  <li>How exactly the scope updated when promise object being resolved? Do i have to update it manually inside the callback or the digest will be automatically invoked and update the rootScope <a href="https://docs.angularjs.org/api/ng/service/%24q#differences-between-kris-kowal-s-q-and-q" rel="nofollow">like declared here</a></li>
  <li>mention at least one approach of updating the scope from within the promise callback</li>
  <li>I assume there a lot of other useful aspects, feel free to provide them all.</li>
  </ol>
  
  <p>I will appreciate and accept the most detailed answer, with as much as possible references to docs or source (that i couldn't find by myself). I can't find any previously discussion  with this topic, if there already was - please post links. </p>
  
  <p>ps: +1 for any one that will help by suggesting a better title for this question, please add your suggestions in a comment.</p>
  
  <p>Cheers!</p>