Wie wird sweetalert2 in angular2 verwendet?

Diesen Fehler nach npm erhalten, starten Sie im Winkelprojekt.

app / app.component.ts (12,7): Fehler TS2304: Name 'swal' kann nicht gefunden werden. app / app.component.ts (21,7): Fehler TS2304: Name 'swal' kann nicht gefunden werden.

Ich habe ein eckiges Projekt erstellt. Innerhalb von app.component.ts habe ich den süßen Alarmcode @ hinzugefüg

export class AppComponent {
deleteRow() {
      swal({
      title: 'Are you sure?',
      text: "You won't be able to revert this!",
      type: 'warning',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes, delete it!'
    }).then(function() {
      swal(
        'Deleted!',
        'Your file has been deleted.',
        'success'
      );
    })
  }
}

Ich ta

npm install sweetalert2 --save 

und fügte auch den Pfad in index.html @ hin

<script src="node_modules/sweetalert2/dist/sweetalert2.min.js"></script>
<link rel="stylesheet" type="text/css" href="node_modules/sweetalert2/dist/sweetalert2.css">

Antworten auf die Frage(8)

Ihre Antwort auf die Frage