title: Promise chaining, chain promise object
body: <p>I would like to chain promise object, but the problem that the second <code>then</code> block is executed before the chained promise object got resolved.</p>
  
  <pre><code>service.webService1()
    .then(data =&gt; {
      if (data.flag) { // true
        return service.webService2() // returns a promise
      }
      return $q.resolve({})
    })
    .then(data =&gt; {
      // some logic
      // data is undefined here, should be the result of
      // service.webService2() call
    })
    .catch(err =&gt; {
      // err handling
    })
  </code></pre>