marcorinck / angular-growl

growl-like notifications for angularJS projects
MIT License
478 stars 191 forks source link

Sometimes single message not shown (angular 1.2.6). #18

Open CalmNad opened 10 years ago

CalmNad commented 10 years ago

Sometimes single message not shown (angular 1.2.6). Сorrected by adding $scope.$apply() to addMessage in directive:

function addMessage(message) {
    $scope.messages.push(message);
    if (message.ttl && message.ttl !== -1) {
        $timeout(function () {
            $scope.deleteMessage(message);
        }, message.ttl);
    }
    $scope.$apply();  // this line fix problem
}
datr commented 10 years ago

Was able to recreate this issue. Suggested fix resolved it for me.

jpdean123 commented 10 years ago

Thanks that fixed the issue for me too.

Not sure if this helps for the developers, but I was finding that sometimes I would need to run a function twice (within the global ttl) to get a msg to show.

For example, I had a notification come up on button click. But I would have to click the button twice within 5 seconds (my global ttl setting) for just one to show up.

Elsewhere I have similar functionality and it seems to be working fine so it is certainly my code that is the issue. But I wasn't getting any errors and putting a console.log("anything") right before the growl. command would console log correctly.

Anyways, thanks for the fix!