-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Looses reference on state change - angular ui-router #25
Comments
@mufsir — Just to make sure I understand correctly:
Is that correct? Thanks! |
@jvandemo : Yes! |
@mufsir — Do you by any chance have a plunk for your scenario? If not, would you be interested in creating one? Thanks! |
https://plnkr.co/edit/2uPR4AFwJ90idMxMhYRY?p=preview Go to Route 2, a couple growls will show. Go to Route 1 and they are no longer dismissible. The TTL is 60 seconds. They'll disappear after the TTL. |
The controller The problem ultimately looks like the controller goes away when you change to a different state. At least when you change states at the same level (sibling or higher). I'd guess a nested state change would continue to work. |
Okay—I see it. UI-router destroys the scope (which exposes the controller) when leaving the state and thus the click handler is not executed as expected. I think it should be possible to create a directive e.g. <growl-notification>
<button close-growl-on-click>Close me</button>
</growl-notification> I will experiment with demo code to see if we can make this happen. Thanks for reporting! 👍 |
I have a working directive right here: |
This worked for the Plunker, but not in practice. There were 2 issues I faced and resolved. First, the directive was only removing itself from the DOM, not the entire Second, since the event handler was running "outside" of Angular, the removal wasn't happening until the next Here's the code I ended up with:
Awesome work BTW! |
@tyriker — Awesome, thank you, great feedback! I will run some additional tests to make sure everything works as expected before adding the directive to the core library. Thanks again — great work! |
I have added a note to the README file with a link to this thread in case someone needs this behavior. No one else has requested this feature before or since, so I'm going to leave it out of the core library for now. If anyone feels it should be added in, please add a comment to this thread. @tyriker—Thank you for your input and feedback! |
When state change happens, I'm not able to close the existing Growl notification using
$growlNotification.remove();
. It only closes when time-out occurs.The text was updated successfully, but these errors were encountered: