1 angular-ui-notification
2 =======================
4 [![Dependency Status](https://david-dm.org/alexcrack/angular-ui-notification.png)](https://david-dm.org/alexcrack/angular-ui-notification)
5 [![devDependency Status](https://david-dm.org/alexcrack/angular-ui-notification/dev-status.png)](https://david-dm.org/alexcrack/angular-ui-notification#info=devDependencies)
6 [![Build Status](https://travis-ci.org/alexcrack/angular-ui-notification.svg?branch=master)](https://travis-ci.org/alexcrack/angular-ui-notification)
7 [![Dependency Status](https://www.versioneye.com/user/projects/54f96af44f3108e7800000e4/badge.svg?style=flat)](https://www.versioneye.com/user/projects/54f96af44f3108e7800000e4)
8 [![Code Climate](https://codeclimate.com/github/alexcrack/angular-ui-notification/badges/gpa.svg)](https://codeclimate.com/github/alexcrack/angular-ui-notification)
10 Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animations
13 * No dependencies except of angular.js.
17 * Use HTML in your messages.
18 * Configure options globally py the provider
19 * Use custom options by the message
24 To install the package using bower and save as a dependency use...
26 bower install angular-ui-notification --save
30 [Heres a plunker demo](http://plnkr.co/edit/5Gk8UVvzUsjyof7Gxsua?p=preview)
33 In your html/template add
36 <link rel="stylesheet" href="angular-ui-notification.min.css">
38 <script src="angular-ui-notification.min.js"></script>
43 In your application, declare dependency injection like so..
46 angular.module('notificationTest', ['ui-notification']);
50 You can configure module by the provider
52 angular.module('notificationTest', ['ui-notification'])
53 .config(function(NotificationProvider) {
54 NotificationProvider.setOptions({
59 horizontalSpacing: 20,
68 And when you need to show notifications, inject service and call it!
71 angular.module('notificationTest').controller('notificationController', function($scope, Notification) {
73 Notification.primary('Primary notification');
75 Notification('Primary notification');
79 Notification.success('Success notification');
82 Notification({message: 'Primary notification', title: 'Primary notification'});
84 // Message with custom delay
85 Notification.error({message: 'Error notification 1s', delay: 1000});
87 // Embed HTML within your message.....
88 Notification.success({message: 'Success notification<br>Some other <b>content</b><br><a href="https://github.com/alexcrack/angular-ui-notification">This is a link</a><br><img src="https://angularjs.org/img/AngularJS-small.png">', title: 'Html content'});
90 // Change position notification
91 Notification.error({message: 'Error Bottom Right', positionY: 'bottom', positionX: 'right'});
94 Notification.error({message: 'Error notification 1s', replaceMessage: true});
100 Module name: "ui-notification"
102 Service: "Notification"
104 Configuration provider: "NotificationProvider"
109 Options can be passed to configuration provider globally or used in the current message.
113 | Option | Possible values | Default value | Description |
114 | ----------------- | ------------------------- | ------------------------------ | ------------------------------------------------------------------------ |
115 | delay | Any integer value | 5000 | The time in ms the message is showing before start fading out |
116 | startTop | Any integer value | 10 | Vertical padding between messages and vertical border of the browser |
117 | startRight | Any integer value | 10 | Horizontal padding between messages and horizontal border of the browser |
118 | verticalSpacing | Any integer value | 10 | Vertical spacing between messages |
119 | horizontalSpacing | Any integer value | 10 | Horizontal spacing between messages |
120 | positionX | "right", "left", "center" | "right" | Horizontal position of the message |
121 | positionY | "top", "bottom" | "top" | Vertical position of the message |
122 | replaceMessage | true, false | false | If true every next appearing message replace old messages |
123 | templateUrl | Any string | "angular-ui-notification.html" | Custom template filename (URL) |
125 Also you can pass the "scope" option. This is an angular scope option Notification scope will be inherited from. This option can be passed only in the methods. The default value is $rootScope
129 #### Notification service methods
131 | Method name | Description |
132 |----------------------------------------|-------------------------------------------------|
133 | Notification(), Notification.primary() | Show the message with bootstrap's primary class |
134 | Notification.info() | Show the message with bootstrap's info class |
135 | Notification.success() | Show the message with bootstrap's success class |
136 | Notification.warning() | Show the message with bootstrap's warn class |
137 | Notification.error() | Show the message with bootstrap's danger class |
138 | Notification.clearAll() | Remove all shown messages |
140 #### Notification service options
142 | Option | Possible values | Default value | Description |
143 | -------------- | ------------------------------------------------ | --------------------------------- | ------------------------------------------------------------------------------------------------------ |
144 | title | *String* | `""` | Title to appear at the top of the notification |
145 | message | *String* | `""` | Message to appear in the notification |
146 | templateUrl | *String* | `"angular-ui-notification.html"` | URL of template to be used for notification |
147 | delay | *Int* (?) | `5000` or configured global delay | Number of ms before notification fades out. If not an integer, notification will persist until killed. |
148 | type | "primary", "info", "success", "warning", "error" | `"primary"` | Bootstrap flavoring |
149 | positionY | "top", "bottom" | `"top"` | |
150 | positionX | "right", "left", "center" | `"right" | |
151 | replaceMessage | *Boolean* | `false` | If true this message will replace old(er) message(s) |
155 Every "show" method returns a promise resolves a notification scope with methods:
157 | Method name | Description |
158 |--------------------------------|------------------------------------------------------------------------------------------------------------------|
159 | notificationScope.kill(isHard) | Remove the specific message<br>isHard - if false or omitted kill message with fadeout effect (default). If true - immediately remove the message|
165 Custom template can be provided.
168 <div class="ui-notification">
169 <h3 ng-show="title" ng-bind-html="title"></h3>
170 <div class="message" ng-bind-html="message"></div>
173 Default existing scope values is "title" - the title of the message and "message".
174 Also any custom scope's properties can be used.