wmluke/angular-flash

Message text not showing

Closed this issue · 6 comments

I am giving this util a try and all seems to be working except the actual message text does not show up. Perhaps flash.message is not being added to the scope as it seems? I am trying with angular 1.0.7.

Also I notice you have some version of this in angular-common, but it appears this is the more recent version. Is that correct?

Thanks! This looks like it should be helpful and clean for dealing with messages.

Hi Shawn,

Can you include some code snippets so I can get a better idea of what's going on?

Also, although angular-common is public, I feel that its not really up to snuff for public consumption. In fact, I plan to break up angular-common into smaller more testable and portable modules, such as angular-flash. Of course you are welcome to fork angular-common and use as-is.

Thanks,
Luke

Hi Luke, thanks for the quick response. So far I have taken the snippets from your readme and added them I also tried adding the alert-block class name incase it was a height issue. Here is what I have:

Bootstrap html:

<div flash-alert active-class="in" class="alert alert-block fade">
   <strong class="alert-heading">Congrats!</strong>
   <span>{{flash.message}}</span>
</div>

In my controller after a service call comes back, I have:

flash.success = 'Project ' + result.title + ' was created.';

The bootstrap alert shows up fine and in the proper color, but without anything from the binding of the message. I have gone into your js file and alerted out the message and it was available there, it just seems that maybe its not being added to the scope.

On a side note I was wondering what the expected way is for the bootstrap flash-alert div to not take up space is. I noticed in your common repo you had display: none, but if I do add that I never see the message. So I assume the fade transition doesnt apply block.

It appears that this is a timing issue. Specifically, the flash service is publishing the success flash before the flash-alert directive has subscribed to flash messages.

I'm working on a fix, but in the meantime as a not-so-nice workaround you can delay the flash.success by throwing it in a timeout...

    // delay flash.success to give the flash-alert directive a chance to subscribe
    $timeout(function () {
        flash.success = 'Project ' + result.title + ' was created.';
    }, 100);

Let me know how it goes.

Awesome, thank you!

Hi!
I have the same trouble with not showing text message. 0.1.8 version is used

x1a0 commented

Hi,

UPDATE
Found the reason. It was because my template engine also interprets {{ }}. Just in case someone would make same mistake...

I am having same issue here too...

angular: 1.2.0-rc.2
angular-flash: 0.1.8

It seems to be something wrong about data-binding. If I use <input type="text" ng-model="flash.message"> then I > can get the message displayed. However {{ flash.message }} doesn't work.