Implementation of alerts

8 views
Skip to first unread message

Hienadź Budkoŭski

unread,
Jul 19, 2017, 1:42:32 PM7/19/17
to Angular and AngularJS discussion
Hi, I am thinking about how is better to implement alert. We have for example alerts from bootstrap = some html code. I m going to create component, place there code html and then if there is an error or exception I will show this component. It's like global component and I have to call it an display my alert message from any other component. The main difficult I don't know better way. I got a thought use component with ngIf and events or subscribe on observable stream for errors, Mb there is the better way?

The main task is be able to display alert message html code from any component, service etc.

Sander Elias

unread,
Jul 19, 2017, 1:50:54 PM7/19/17
to Angular and AngularJS discussion
Angular material uses a toast for this, perhaps you can take a look at that?

Tito

unread,
Jul 19, 2017, 2:00:18 PM7/19/17
to Angular and AngularJS discussion
I use the following, and it displays a very nice toast message instead of using oogly alert function

function VirtualMachines($state, $scope, $filter, $log, $sce, $sanitize, toastr, dataservice, logger) {
...
...
toastr.info('Virt Un-Marked for Deletion', 'Virt Un-Marked for Deletion');

Hienadź Budkoŭski

unread,
Jul 19, 2017, 2:33:18 PM7/19/17
to Angular and AngularJS discussion
I saw material toasts and others, but it's interesting for me more as structured design, I say in another words, cause the toast seems good and to easy..
We need to display and manage(change text etc) one piece of html code on the page, and provide access from any component.

Now I get idea about use component+service, service provide methods show edit hide and component will react and manage html view.
It's just matter of structure design and understanding angular.
PS Thx for replies :)

Reply all
Reply to author
Forward
0 new messages