Как использовать sweetalert2 в angular2
Получение этой ошибки после запуска npm в угловом проекте.
app / app.component.ts (12,7): ошибка TS2304: не удается найти имя «swal». app / app.component.ts (21,7): ошибка TS2304: не удается найти имя «swal».
Я создал угловой проект. Внутри app.component.ts я добавил приятный код оповещения
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'
);
})
}
}
я сделал
npm install sweetalert2 --save
а также добавил путь в index.html
<script src="node_modules/sweetalert2/dist/sweetalert2.min.js"></script>
<link rel="stylesheet" type="text/css" href="node_modules/sweetalert2/dist/sweetalert2.css">