title: angular2 with sweetalert2 that prompts then gives a response
body: <p>I have an mvc with angular2 website.  I want to give a sweetalert2 message asking the user to confirm they want to update their data.  If they confirm I need the sweetalert2 box to show the loading/waiting while the service calls the server to update the data.  The server call responseds with a bool to let the user know if the update was successful or not, which I want to display with a sweetalert2 success or error dialog.  Below is my code, but my console gives me the error: 'Unhandled Promise rejection: Unexpected token &lt;...'.  This is my first angular2 app and first time using sweetalert2 and can't seem to find an example without an ajax call.  </p>
  
  <p>My service originally returned an Observable and my component had the .subscribe(...), but I changed it to a boolean thinking it would work in the Promise.  The service's postaction calls my ServiceAdapter class that does the http.post.</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>I figured out how to get it to show the loading while the preConfirm runs, but it can't seem to call service.  I simulate the service call taking time with the settimeout(...,5000).  After the 5 secs I get the console error: Cannot read property 'updateStuff' of undefined.  How do I get it to call this._myService? </p>
  
  <p><strong>UPDATE 2 / Answer</strong></p>
  
  <p>Updating this in case anyone else needs the same workflow.
  I did figure out how to get the workflow I needed.  This gives an initial message, then shows the loading screen while waiting for the service response.  It then gives me a success or error message based on the service's response.</p>
  
  <p>Code updated to latest version.</p>
  
  <pre><code>inside my component:
  constructor(private _myService: MyService){}
  
  
   onUpdateClick(){
       swal({
           title: 'Update?',
           text: 'Are you sure you want to update stuff?',
           showCancelButton: true,
           allowOutsideClick: false,
           showLoaderOnConfirm: true,
           preConfirm: function () {
               return new Promise(() =&gt; {
                       (this._myService.updateStuff(this.selectedId, this.updateObject)
                           .subscribe((result: boolean) =&gt; {
  
  
                               if (result.length &gt; 0) {
                                   console.log("it worked with msg: " + result);
                                   swal('It worked', 'stuff was updated', 'success');
                               }
                               else {
                                   console.log("it died with error: " + result);
                                   swal('It failed', 'nothing updated', 'error');
                               }
                           }
                      ))
                   });
           }
       }).catch(function (arg) {
           console.log("exited b/c " + arg);
           swal({
               type: 'error',
               title: 'failure',
               html: 'some error response'
           })
       });
   }
  
  
  my service:
  updateStuff(selectedId number, updateObject: UpdateObject): Observable&lt;boolean&gt;{
      var params: Object = { selectedId: selectedId, updateObject: updateObject };
      var result = this.postaction(params, 'myControllerPath' )
      return result;
  }
  </code></pre>
  
  <p>Thanks in advance for the help</p>