title: How to master this conditional promise in angular?
body: <p>I must solve a problem in <code>angularjs</code> and I'm stuck for some hours right now.</p>
  
  <p>if have this pseudo code:</p>
  
  <pre><code>doSomething(param){
  
      var res;
      if(param = "ok"){
          //do some api calls with promise
          res = promise result
       }
  
      doSomeStuff(){
          //if i got res variable, continue with this...
          // else
          //if res is not set, do this...
      }
  </code></pre>
  
  <p>So my question is: How i can do something like this?
  The <code>doSomeStuff</code> function needs to know, if variable <code>res</code> is set or not. So it needs to wait, or to continue, if the variable <code>res</code> is not set.</p>