wmluke/angular-flash

Setting two flash messages with different type will add both types as the class

mikz opened this issue · 2 comments

mikz commented

Imagine this example:

flash.info = 'Saving...';
object.save(function(){ flash.success = "Object saved"; });

It correctly replaces the message with 'Object saved', but it does not remove the original 'alert-info' class so it shows 'Object saved' with two classes: 'alert-info' and 'alert-success'.

using this template:

<div flash-alert class="alert">
  <span class="alert-message">{{flash.message}}</span>
</div>

If you are ok with me fixing it I could make a PR. Lets just figure out some solution you would be happy with.

I suspect this is related to #2. To test my theory, would you mind wrapping flash.info = 'Saving...'; in a $timeout?

Something like...

$timeout(function(){
    flash.info = 'Saving...';
},100);

object.save(function(){ flash.success = "Object saved"; });

Thanks,
Luke

mikz commented

Both are showing. The first one just blinks and the other is shown. The issue is that the first class "info" is not removed when the "success" is shown.

The example would show the info after the success and it would also have both classes.