angular-flash icon indicating copy to clipboard operation
angular-flash copied to clipboard

flash.to with dynamic ids

Open spiermar opened this issue 10 years ago • 2 comments

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?

spiermar avatar Dec 18 '14 23:12 spiermar

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

omarqureshi avatar Apr 17 '15 11:04 omarqureshi

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';

omarqureshi avatar Apr 17 '15 11:04 omarqureshi