Created
July 3, 2021 10:47
-
-
Save Isurie/ee514fa8ce633de2d1aa5feb2a2d7453 to your computer and use it in GitHub Desktop.
Create Dialog box component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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..!') | |
} | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor(public dialogRef: MatDialogRef<DialogBoxComponent>, | |
@Inject(MAT_DIALOG_DATA) public data: any) { } | |
onNoClick(): void { | |
this.dialogRef.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gracias por la info!