Skip to content

Instantly share code, notes, and snippets.

@Isurie
Created July 3, 2021 10:47
Show Gist options
  • Save Isurie/ee514fa8ce633de2d1aa5feb2a2d7453 to your computer and use it in GitHub Desktop.
Save Isurie/ee514fa8ce633de2d1aa5feb2a2d7453 to your computer and use it in GitHub Desktop.
Create Dialog box component
openDialog(row_obj:any): void {
let dialogRef = this.dialog.open(DialogBoxComponent, {
width: '250px',
data: { name: this.name }
});
dialogRef.afterClosed().subscribe(result => {
this.name = result;
if(this.name!=undefined){
if(this.name==""){
Swal.fire('Username cannot be empty..!')
}else{
row_obj.userName=this.name
const newUsersArray = this.USER_DATA;
this.myDataArray = [...newUsersArray];
Swal.fire('Updated successfully..!')
}
}
});
}
<h1 mat-dialog-title>Row Action :: Update</h1>
<div mat-dialog-content>
<p>Update Name</p>
<mat-form-field>
<input matInput [(ngModel)]="data.name">
</mat-form-field>
</div>
<div mat-dialog-actions>
<button mat-button (click)="onNoClick()">Cancel</button>
<button mat-button [mat-dialog-close]="data.name"
cdkFocusInitial>Update</button>
</div>
constructor(public dialogRef: MatDialogRef<DialogBoxComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) { }
onNoClick(): void {
this.dialogRef.close();
}
@KeyCuevasMelgarejo
Copy link

Gracias por la info!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment