alexcrack / angular-ui-notification

Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating
MIT License
536 stars 169 forks source link

maxcount is not working #101

Open fidelove opened 7 years ago

fidelove commented 7 years ago

I have configured the param maxcount, but it seems not to be working.

Looking into the code seems like only the default value is used.

Thanks in advance

zygmcc commented 7 years ago

do you change this.options = { delay: 2000, startTop: 10, startRight: 10, verticalSpacing: 10, horizontalSpacing: 10, positionX: 'center', positionY: 'top', replaceMessage: false, templateUrl: 'angular-ui-notification.html', onClose: undefined, closeOnClick: true, maxCount: 2, // 0 - Infinite container: 'body' }; the param: "maxCount"? My project works well with angularjs 1.4.6

zygmcc commented 7 years ago

the param: "maxCount" default is 0, means infinite

fidelove commented 7 years ago

Hello,

I have injected the parameters in the notification constructor:

 Notification.primary({
 templateUrl: 'partials/notification.html',
 scope: $notifScope,
 delay: notification.displayTime,
 positionY: notification.yPosition,
 positionX: notification.xPosition,
 maxCount: notification.maxCount, 
 onClose: function() {
      console.log('Close Notification');
 }

notification is an object received from the back, and it is correctly initialised with all the requested values.

May the problem come from transpilation from TypeScript to javascript?

As workaround I manually check the number of displayed notifications.

Thanks in advance and best regards.

zygmcc commented 7 years ago

@fidelove your "notification" object came from an Angular promise? If so , try to use synchronization way instead of asynchronous

RodrigoPetter commented 6 years ago

I was doing some tests and despite the documentation in this link that says

Options can be passed to configuration provider globally or used in the current message.

Some options only work in the configuration of the provider like :

.config(function(NotificationProvider)` {
        NotificationProvider.setOptions({
            delay: 10000,
            maxCount: 5
        });

A working example can be found here

But I realy would like to see it working as a message parameter, because in my case, depending on the situation, I need to show it with differents numbers. Exemplo: Top-Right stack in 15 itens and Bottom-Right stack in 3.

Some one can confirm if this is the expected behavior? There is some way that I can achieve the discribed exemple?

n-lavrenko commented 5 years ago

This is not working if I should change maxCount dynamically. I'm incredibly upset. I will fork this repo for make a fix. So, this code should work, but no:

abstract: true,
controllerAs: 'vm',
onEnter: function() {
     NotificationProvider.setOptions({
            maxCount: 99
     });
  },
onExit: function() {
   NotificationProvider.setOptions({
           maxCount: 3
    });
}