|
[app.component.ts]
private BtnClick(): void {
// render confirm utility dialog
this.UtilComponent = DialogUtility.confirm({
title: ' Confirmation Dialog',
content: "This is a Confirmation Dialog!",
// bind okClick function to ok button’s click event
okButton: { text: 'OK', click: this.okClick.bind(this) },
// bind cancelClick function to cancel button’s click event
cancelButton: { text: 'Cancel', click: this.cancelClick.bind(this)},
showCloseIcon: true
});
}
private okClick(args): void {
// to hide confirm Dialog when click on the ok button.
this.UtilComponent.hide();
} |
|
// To change the dialog button text value after localization changed dynamically in drop-down.
public changeButtonText(locale: string): void {
let okButton: any; let cancelButton: any
if (!isNullOrUndefined(this.UtilComponent.getButtons())) {
okButton = this.UtilComponent.getButtons()[0];
cancelButton = this.UtilComponent.getButtons()[1];
}
this.getLocaleText(locale);
okButton.content = this.okButtonText;
cancelButton.content = this.cancelButtonText;
}
// Method to assign the buttonText based on localization
public getLocaleText(locale: string) {
switch (locale) {
case 'en-US':
this.okButtonText = 'Ok';
this.cancelButtonText = 'Cancel';
break;
case 'fr-BE':
this.okButtonText = "D'accord",
this.cancelButtonText = 'Fermer';
break;
case 'zh-CN':
this.okButtonText = "好";
this.cancelButtonText = '關';
break;
}
}
ngOnInit() {
// Load French culture for Dialog close button tooltip text
L10n.load({
'fr-BE': {
'dialog': {
'close': "Fermer"
}
},
'zh-CN': {
'dialog': {
'close': "關"
}
}
});
// Pass initial localization value
this.getLocaleText('en-US');
} |