Giter Club home page Giter Club logo

Comments (5)

mribichich avatar mribichich commented on June 13, 2024

+1

from angular-growl-notifications.

jvandemo avatar jvandemo commented on June 13, 2024

If you want the object to stay in sync with the notifications in your UI, you can use the $timeout service to accomplish this:

$scope.add = function(notification){
  var i;

  if(!notification){
    $scope.invalidNotification = true;
    return;
  }

  i = index++;
  $scope.invalidNotification = false;
  $scope.notifications[i] = notification;
  $timeout(function(){
    delete $scope.notifications[i];
  }, timeoutOfYourNotification);
};

Can you let me know if that provides you with your desired behavior?

May I ask what the use case is in your application? Then I can get a better idea if this needs better support.

Thanks in advance!!

from angular-growl-notifications.

frantisekbrabec avatar frantisekbrabec commented on June 13, 2024

The goal would be to have an array to represent individual notifications.
Then in spirit of AngularJS removing a notification on the screen (e.g.,
pressing the 'x' button or by reaching the TTL set within the HTML) would
also remove the corresponding element from the array (i.e., array length
would be previous length -1); correspondingly removing an element from the
array in javascript (e.g., splice) would remove the notification from the
screen.

On Mon, Sep 14, 2015 at 11:38 AM, Jurgen Van de Moere <
[email protected]> wrote:

If you want the object to stay in sync with the notifications in your UI,
you can use the $timeout service to accomplish this:

$scope.add = function(notification){
var i;

if(!notification){
$scope.invalidNotification = true;
return;
}

i = index++;
$scope.invalidNotification = false;
$scope.notifications[i] = notification;
$timeout(function(){
delete $scope.notifications[i];
}, timeoutOfYourNotification);
};

Can you let me know if that provides you with your desired behavior?

May I ask what the use case is in your application? Then I can get a
better idea if this needs better support.

Thanks in advance!!


Reply to this email directly or view it on GitHub
#17 (comment)
.

from angular-growl-notifications.

jvandemo avatar jvandemo commented on June 13, 2024

@frantisekbrabec — Okay, I understand your use case.

If you need synchronization of notifications with an array, there may be more appropriate solutions like angular-toastr or even angular-cache if you want to implement your own notifications system.

This library was designed to be completely declarative using a simple directive in the view, which keeps it very light and fast, but also limited in its API, making it a less appropriate choice if you need more programmatic control.

However, you can still accomplish what you need using the code I posted above.

Thanks for your feedback, really helpful and truly appreciated!

from angular-growl-notifications.

jvandemo avatar jvandemo commented on June 13, 2024

I will close this issue for now, feel free to add comments in case of additional questions or opinions.

from angular-growl-notifications.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.