Comments (5)
+1
from angular-growl-notifications.
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.
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.
@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.
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)
- Cannot read property 'parent' of undefined HOT 3
- Publish on NPM HOT 1
- Render same notification multiple times HOT 1
- Shows first time, then nomore HOT 4
- Angular expressions in strings (interpolation) HOT 1
- Custom css for each notification
- Error: after is undefined HOT 3
- growl notification ttl is not getting applied HOT 7
- on-close not working HOT 2
- how do i instal it on windows and without using bower? HOT 1
- Looses reference on state change - angular ui-router HOT 10
- Inline HTML HOT 5
- (Proposal) Replace $timeout with $interval (Accommodate Protractor tests) HOT 4
- Cannot read property 'parent' of undefined HOT 3
- on-close function gets called immediately HOT 3
- unable to download 2.6.0 version HOT 1
- on-open, on-close not in complete documentation
- class="ng-scope" error in dev console HOT 1
- Error: after is undefined HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-growl-notifications.