1- import { Component , OnInit , ViewChild } from '@angular/core' ;
1+ import { Component , OnInit , ViewChild , Inject } from '@angular/core' ;
22import { animate , state , style , transition , trigger } from '@angular/animations' ;
33import { MatTable } from '@angular/material/table' ;
4+ import { MatDialog , MAT_DIALOG_DATA } from '@angular/material/dialog' ;
45import { BarcodeScanner } from '@awesome-cordova-plugins/barcode-scanner/ngx' ;
56
67export interface InvoiceElement {
@@ -32,7 +33,7 @@ export class AfipComponent implements OnInit {
3233 expandedElement : InvoiceElement | null | undefined ;
3334 @ViewChild ( MatTable ) table : MatTable < InvoiceElement > | undefined ;
3435
35- constructor ( private barcodeScanner : BarcodeScanner ) { }
36+ constructor ( private barcodeScanner : BarcodeScanner , public dialog : MatDialog ) { }
3637
3738 ngOnInit ( ) : void {
3839 let inv = localStorage . getItem ( 'invoices' ) ;
@@ -80,7 +81,7 @@ export class AfipComponent implements OnInit {
8081 this . table ! . renderRows ( ) ;
8182 }
8283 } else {
83- alert ( 'El QR escaneado no es de AFIP' ) ;
84+ this . openDialog ( 'El QR escaneado no es de AFIP' ) ;
8485 }
8586 }
8687
@@ -181,4 +182,20 @@ export class AfipComponent implements OnInit {
181182 link . click ( ) ;
182183 }
183184
185+ openDialog ( msg : string ) {
186+ const dialogRef = this . dialog . open ( DialogContent , {
187+ data : msg ,
188+ } ) ;
189+
190+ dialogRef . afterClosed ( ) . subscribe ( result => { } ) ;
191+ }
192+
184193}
194+
195+ @Component ( {
196+ selector : 'dialog-data' ,
197+ templateUrl : './dialog.html' ,
198+ } )
199+ export class DialogContent {
200+ constructor ( @Inject ( MAT_DIALOG_DATA ) public data : string ) { }
201+ }
0 commit comments