moff / angular2-flash-messages

Angular 2 flash messages module
52 stars 21 forks source link

not working on redirect to another component #29

Open vk011 opened 6 years ago

vk011 commented 6 years ago

Hello,

I have it all set in one component and there flash messages work, however if i redirect from that component to another component (where I have imported the package and added it as a dependency in the constructor and the view tags in its template), I do not see the error message and after the timeout I get this error:

ERROR Error: ViewDestroyedError: Attempt to use a destroyed view: detectChanges
    at viewDestroyedError (core.es5.js:8451)
    at Object.debugUpdateDirectives

Is it even possible?

moff commented 6 years ago

@vk011 thanks for your feedback! Can you please check if it works with updated version of the package?

Senegal commented 6 years ago

this problem is still alive for me. If try to navigate by route while alert is showing -got same error in console

mikebrsv commented 6 years ago

You should place <flash-messages></flash-messages> into the parent component.

susheelbanyal commented 6 years ago

I am heaving the same issue. While redirecting and if the flash message is still there then it shows the view destroy error. ERROR Error: ViewDestroyedError: Attempt to use a destroyed view: detectChanges at viewDestroyedError (core.es5.js:8451) at Object.debugUpdateDirectives I have separate components. So there is only one parent which is app.component.html. I am redirecting to the same level.

I have comment **angular2-flash-message/module/flash-messages.component.js** on line number 36 comment 
//this._cdRef.detectChanges();

and it is working. Please suggest a better solution. I don't want to change the main module. Advance thanks