angular-flash
angular-flash copied to clipboard
flash.to with dynamic ids
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?
I'd also like to do something similar here - @spiermar what did you end up doing?
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';