Skip to content

Instantly share code, notes, and snippets.

@anteburazer
Created June 5, 2017 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anteburazer/afb52e829aecdacc6fae64943f9017b0 to your computer and use it in GitHub Desktop.
Save anteburazer/afb52e829aecdacc6fae64943f9017b0 to your computer and use it in GitHub Desktop.
/**
* Translates given message code and title code and
* displays corresponding notification
*
* @param msgCode
* @param type
* @param titleCode
*/
public displayNotification(msgCode: string, type: string = 'info', titleCode?: string) {
let message: string = this.translateService.instant(msgCode);
let notificationOpts: any = this.configService.get('notifications').options;
let title: string = titleCode ? this.translateService.instant(titleCode) : null;
switch (type) {
case "error":
title = this.translateService.instant('ErrorTitle');
break;
case "success":
title = this.translateService.instant('SuccessTitle');
Break;
default:
title = this.translateService.instant('InfoNotificationTitle');
break;
}
this.notificationService[type](title, message, notificationOpts);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment