title: Angular 2 - Sweet alert call back function not working
body: <p>I am trying to delete an item in my angular cli app. I've used sweet alert as an alert and i want to delete an item from the list. Here is a code for that. This code is in typescript file.</p>
  
  <pre><code>import { AuthenticationService } from '../../../services/authentication.service';
  declare var swal: any;
  export class AdminUsersComponent implements OnInit {
  
      constructor(
          private authService: AuthenticationService,
      ) { }
  
      deleteUser(id) {
          let userData = {
             user_id: id
          };
          swal({
              title: "Are you sure?",
              text: "You will not be able to recover this!",
              type: "warning",
              showCancelButton: true,
              confirmButtonColor: "#DD6B55",
              confirmButtonText: "Yes, delete it!",
              closeOnConfirm: false
          }, function(){
              this.authService.deleteUser(userData).subscribe(data =&gt; {
                  // response
              });
          });
  
      }
  }
  </code></pre>
  
  <p>Problem is when i confirm delete, it gives me error that "this.authserivce "is undefined. It is working properly if i don't use sweet alert as confirmation. I'm guessing i need to pass parameter in call back function but don't know what should i pass. So how i can solve this?</p>