I'm using Material Angular (from Angular Material). The examples in the site seem a Little too overcomplicated and every other tutorial in the internet seems either outdated or to be using AngularJS instead. How can I show a simple alert (just like Android's AlertDialog) with a title, a message and a confirm/cancel button?
The MatDialog service can be used to open modal dialogs with Material Design styling and animations.
In the dialog component, we need to create an instance of 'MatDialogRef' which we should import from '@angular/material/dialog'. Import 'MatDialogModule' from '@angular/material' in app. module. ts file.
You can pass any kind of data to the component by adding data to the MatDialog's open() options. }, }); You can retrieve the data by injecting MAT_DIALOG_DATA in the opened component.
I had used a sweet Alert. https://www.freakyjolly.com/angular-sweetalert2-tutorial/#.X2nNxmgzZPY
It´s the most easy and fast method to create alerts in angular.
$ npm install --save sweetalert2
Use import Swal from 'sweetalert2';
in your TS file together with the Alert Swal.fire('This is a simple and sweet alert')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With