Sweetalert2 for angular x cli application.
npm i -s ngx-sweetalert2
Add the following sections to the .angular.cli.json
file.
"styles": [
"../node_modules/sweetalert2/dist/sweetalert2.css"
],
"scripts": [
"../node_modules/sweetalert2/dist/sweetalert2.js"
],
Next, inject SweetAlertService
into a component or module:
import { SweetAlertService } from 'ngx-sweetalert2';
@Component({
providers: [SweetAlertService]
})
export class MyComponent {
constructor(private _swal2: SweetAlertService) {
this._swal2.success({ title: 'This is a alert' });
}
}
import { SweetAlertService } from 'ngx-sweetalert2';
@NgModule({
providers: [SweetAlertService]
})