question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Display toastr after http post request does not work

See original GitHub issue

Hello,

I’d like display an green toastr in case of success and a red in case of error after an http post request.

It’s strange because when I put the code this.toastrService.success('Hello world!', 'Toastr fun!'); in ngOnInit I see the toastr

I see the ‘OK’ in the console, the line just before the call to toastrService.

Here the link to the code https://pastebin.com/SQxXxvU5

What’s wrong ?

Thanks,

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SebasG22commented, Aug 23, 2018

@Kris-I the example above is based on angular project with RXJS. You can get more information here: https://angular.io/guide/rx-library

But if you are creating a simple project just need to use :

this.zone.run(() => { this.toastr.error('Message Description', 'Message Title'); })

Don’t forget to provide in the constructor

import { NgZone } from '@angular/core';

// You can use on a service or component 

constructor(private zone: NgZone){}

public showErrorMessage(title: string, description: string){
this.zone.run(() => { this.toastr.error(description, title); })

}

@yarrgh @scttcper This issue can be closed.

1reaction
trevor-hackettcommented, Aug 13, 2018

Nevermind. Figured out the animation error. StackBlitz pulled in @angular/animations 6.1 while the rest of @angular was on 6.0.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Display message in a toastr after controller method finish
In your http post action method, after successful upload, set an entry to TempData dictionary and read it in the next view which...
Read more >
Handling HTTP Error Messages Globally using Interceptors ...
Handle all HTTP error messages in your whole Angular app using Interceptors and NGX-Toaster. What are Interceptors?
Read more >
Handling HTTP Error Messages `Globally` using Interceptors ...
Handle all HTTP error messages in your whole Angular app using Interceptors and NGX-Toaster. What are Interceptors?
Read more >
Handle http responses with HttpInterceptor and Toastr in ...
In this article I will show you how to deal with it, by using an http interceptor and the ngx-toastr plugin to display...
Read more >
How to flash Toastr error message if validation fails when ...
'Changes has been saved'); return back(); I got no place to post error ... <?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found