title: Sweetalert as a service in Angular
body: <p>I´m trying to create a CRUD in Angular. Aparently the CRUD works but i want to improve code so i need avoid some sweetalert  code to use only once. I think I can create a service and create different functions, like this</p>
  
  <pre><code>export ModalClass{
      showconfirmdialog(title, text, icon){
      swal({
        title: "Are you sure?",
        text: "Once deleted, you will not be able to recover this imaginary file!",
        icon: "warning",
        buttons: true,
      })
      .then((willDelete) =&gt; {
        if (willDelete) {
          swal("Poof! Your imaginary file has been deleted!", {
            icon: "success",
          });
        } else {
          swal("Your imaginary file is safe!");
        }
      });
      }
  }
  </code></pre>
  
  <p>Then in .ts file <em>inject</em> this class and functions like this</p>
  
  <pre><code>import {ModalClass} from 'blabla'
      deletefunction(){
           this.http.get('API').subscribe()
           this.ModalClass.showconfirmdialog('Was deleted','all ok', 'fa-ok')
       }
  </code></pre>
  
  <p>Nothing happens. I debug response and return something like</p>
  
  <blockquote>
    <p>[Object Object]</p>
  </blockquote>
  
  <p>So the question is : How can i create a service with reutilizable code and inject this in ts files?</p>