Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JHipster - JhiAlertService - How to decide how long alerts are displayed?

Tags:

jhipster

I have generated a JHipster project with version 4.9.0.

I am using the JhiAlertService to display various messages to users.

I would like to know how to send in parameters to indicate how long the messages are displayed.

like image 706
Orn Arnar Avatar asked Dec 23 '22 09:12

Orn Arnar


1 Answers

JhiAlertService comes from the ng-jhipster library.

You can view the code of alert.service.ts to see the available parameters. For customizing the timeout, use the addAlert method and pass it a JhiAlert object containing a timeout parameter:

this.alertService.addAlert({type: 'success', msg: 'A short message', timeout: 1000}, []);

Note that if you are using the i18n option, the msg field is the name of the i18n JSON key, and the params field should contain any information that is interpolated into the message. So for displaying an alert when the "Admin" user is saved successfully, you would use:

this.alertService.addAlert({type: 'success', msg: 'userManagement.updated', params: { param: 'admin' }, timeout: 1000}, []);
like image 75
Jon Ruddell Avatar answered Apr 28 '23 05:04

Jon Ruddell