title: Angular 2 waiting for promise and observable to resolve
body: <p>In my accountService, I have a dialog that asks the user for username/password which returns a promise.  If they click close rather than dismiss and the validators require the data before they can click close, then I want to log in with that data which returns an observable.  </p>
  
  <pre><code>loginModal() : boolean {
  
      this.dpDialogService.input(
          'Login',
          [
              {
                  label: 'Username/Email', 
                  form: 'username', 
                  data: '', 
                  validators: [Validators.required],
                  validatorMsg: 'Username is required.'
              },
              {
                  label: 'Password', 
                  form: 'password', 
                  data: '', 
                  validators: [Validators.required],
                  validatorMsg: 'Password is required.',
                  type: 'password'
              },
          ]
      ).then(
          close =&gt; {
              this.login({username: close.username.value, password: close.password.value}).subscribe(
                  loginResult =&gt; {
                      return true;
                  },
                  errorResult =&gt; {
                      this.dpDialogService.error('Invalid username/password.');
                      return false;
                  }
              )
          },
          dismiss =&gt; {
              return false;
          }
      );
  }
  </code></pre>
  
  <p>How do I return this boolean from the function.  I am guessing I have to use a promise but not sure how with them being nested.</p>