Nerdy Programmers Mingling


    2.6.0 • Public • Published

    AngularJS Growl Notifications

    Growl notifications for AngularJS

    Build Status

    Notifications logically belong inside the view layer of your application.

    Most existing growl systems require you to add notifications using JavaScript inside your controller layer.

    This very lightweight library (<2KB) allows you to declaratively create notifications using directives only, supporting both inline expressions and HTML.

    Think Growl, but in AngularJS directives. Oh, and Bootstrap compatible too.

    Official website

    Quick start

    Learn how to create Mac OS X like pop-up notifications in your AngularJS application.

    STEP 1: Install the library

    Download the code from GitHub or install it using bower:

    $ bower install angular-growl-notifications

    Load the library in your markup:

    <script type="text/javascript" src="angular.js"></script>
    <script type="text/javascript" src="angular-growl-notifications.js"></script>

    Load the growlNotifications module in your AngularJS application:

    angular.module('yourApp', ['growlNotifications']);

    The library is now loaded in your AngularJS application.

    STEP 2: Specify where you want to render the notifications

    Before you can create notifications, you need to add the growl-notifications (plural) directive to your markup.

    This directive allows you to control where the notifications are rendered in your DOM in case your application requires special behavior.

    In most cases you should simply add it as the first element inside the body element:


    Check out the growl-notifications directive documentation for more information.

    STEP 3: Create notifications

    You can now use the growl-notification (singular) directive to create notifications anywhere in your application:

    <!-- This notification will be shown when the page loads -->
      Hello world

    You can use AngularJS expressions:

    <!-- This notification will be shown when the page loads -->
      Hello {{name}}

    and HTML:

    <!-- This notification will be shown when the page loads -->
      Hello <strong>{{name}}</strong>

    Most of the time you will want to show a notification when some event occurs. You can use the native AngularJS ng-if directive to make this happen:

    <!-- This notification will be shown when showNotification becomes truthy -->
    <growl-notification ng-if="showNotification">
      showNotification just became truthy

    By default notifications are shown for 5 seconds, but you can specify the ttl in milliseconds for every notification individually:

    <growl-notification ttl="1000">
      Only show me for 1000ms

    A ttl of -1 or false will disable the automatic closing timeout, making the notification permanent. You will need to close the notification manually using $growlNotification.remove().

    You can also specify handlers you wish to run when the notification opens and closes:

    <growl-notification on-open="doSomething()" on-close="doSomethingElse()">

    which is convenient if you want to auto-reset some state when the notification is closed:

    <button ng-click="showNotification = true">Show notification</button>
    <!-- reset showNotification to false again when notification is closed -->
    <!-- so the ng-if is triggered every time the button is clicked -->
    <growl-notification ng-if="showNotification" on-close="showNotification = false">

    Check out the growl-notification directive documentation for all available options.

    STEP 4: Customize look and feel

    By default no styling is applied so you can completely control the look and feel of the notifications in your application's stylesheet.

    The possibilities are endless, for example to display notifications in the top right of your page:

      position: fixed;
      top: 150px;
      right: 10px;
      border: 1px solid black;
      padding: 15px 30px;
      margin-bottom: 15px;

    That's it

    Hello world

    You now have a working notification system in your AngularJS application.

    When you load the page, a "Hello world" notification will automatically appear and disappear.

    There are many additional features and options, so make sure to visit the examples page for more inspiration and sample code.

    Manually closing notification after a UI-Router state change

    If you find yourself in a rare situation where you need to manually close a notification after a state change, you can create a custom directive as demonstrated in this plunk and discussed in this thread.



    Change log


    • Added support for permanent notifications. Setting ttl to -1 or false will keep notifications visible until manually closed (e.g with $growlNotification.remove());


    • Add support for infinite notification (#31)


    • Replace $timeout with $interval to fix #28


    • Updated timeout cancel mechanism (#27)


    • Updated angular dependency version (#22)


    • Added support for on-open handler
    • Added support for on-close handler
    • Updated documentation


    • Make angular dependency version less strict


    • Fix issue with injection of $animate in controller of growlNotification directive



    • Fix issue with minification of controller in growlNotification directive (see this issue).


    • Directives have been rewritten for better performance
    • Now supports manually closing notifications using markup
    • v1 release has been moved to v1.x.x branch


    • Added support for custom css prefix (defaults to Bootstrap alert)


    • The growl-notifications directive now uses an isolate scope


    • Added support for custom options in growl-notification directive
    • Updated demo page


    • Added $animate support
    • Updated demo page


    • Added dist directory with pre-built library files
    • Added demo page


    • Added growl-notification directive to conveniently add notifications from within HTML markup
    • Added growl-notifications directive to conveniently display notifications from within HTML markup
    • Added documentation


    • Initial version


    npm i angular-growl-notifications

    DownloadsWeekly Downloads






    Last publish


    • jvandemo