Skip to content
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

flash.to with dynamic ids #43

Open
spiermar opened this issue Dec 18, 2014 · 2 comments
Open

flash.to with dynamic ids #43

spiermar opened this issue Dec 18, 2014 · 2 comments

Comments

@spiermar
Copy link

I have something like this:

<div id="{{ 'alert-disklatency-error-' + id }}" flash-alert="error" active-class="in alert" class="fade">
    <strong class="alert-heading">Error!</strong>
    <span class="alert-message">{{flash.message}}</span>
</div>

Where the div id is being generated dynamically. The id variable is coming from a directive. Inspecting the element once the page is loaded, the element id is resolved correctly.

If I try this:

flash.to("alert-disklatency-error-" + String(id)).error = 'error!';

Nothing is displayed. Again, the id is being resolved correctly, and if I remove the id from the equation, the alert is displayed correctly.
Unfortunately, I need dynamically generated Ids, since I'll have objects being created dynamically.

Any ideas?

@omarqureshi
Copy link

I'd also like to do something similar here - @spiermar what did you end up doing?

@omarqureshi
Copy link

Actually, this does seem to work. What I did was:

<div ng-attr-id="{{ 'session-saved-' + session.id }}" flash-alert active-class="in alert session-alert" class="fade">
  <span class="alert-message">{{flash.message}}</span>
</div>

With javascript of

flash.to('session-saved-' + session.id).info = 'Session updated';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants