@@ -103,6 +103,7 @@ angular.module('patternfly.notification').provider('Notifications', function ()
103103 this . delay = 8000 ;
104104 this . verbose = true ;
105105 this . notifications = { } ;
106+ this . notifications . data = [ ] ;
106107 this . persist = { 'error' : true , 'httpError' : true } ;
107108
108109 this . setDelay = function ( delay ) {
@@ -119,7 +120,7 @@ angular.module('patternfly.notification').provider('Notifications', function ()
119120 this . persist = persist ;
120121 } ;
121122
122- this . $get = [ '$rootScope' , '$ timeout', '$log' , function ( $rootScope , $timeout , $log ) {
123+ this . $get = [ '$timeout' , '$log' , function ( $timeout , $log ) {
123124 var delay = this . delay ;
124125 var notifications = this . notifications ;
125126 var verbose = this . verbose ;
@@ -132,15 +133,8 @@ angular.module('patternfly.notification').provider('Notifications', function ()
132133 warn : { type : 'warning' , header : 'Warning!' , log : 'warn' }
133134 } ;
134135
135- $rootScope . notifications = { } ;
136- $rootScope . notifications . data = [ ] ;
137-
138- $rootScope . notifications . remove = function ( index ) {
139- $rootScope . notifications . data . splice ( index , 1 ) ;
140- } ;
141-
142- if ( ! $rootScope . notifications ) {
143- $rootScope . notifications . data = [ ] ;
136+ if ( ! notifications ) {
137+ notifications . data = [ ] ;
144138 }
145139
146140 notifications . message = function ( type , header , message , isPersistent , closeCallback , actionTitle , actionCallback , menuActions ) {
@@ -156,7 +150,7 @@ angular.module('patternfly.notification').provider('Notifications', function ()
156150 } ;
157151
158152 notification . show = true ;
159- $rootScope . notifications . data . push ( notification ) ;
153+ notifications . data . push ( notification ) ;
160154
161155 if ( ! notification . isPersistent ) {
162156 notification . viewing = false ;
@@ -198,14 +192,15 @@ angular.module('patternfly.notification').provider('Notifications', function ()
198192 } ;
199193
200194 notifications . remove = function ( notification ) {
201- var index = $rootScope . notifications . data . indexOf ( notification ) ;
195+ var index = notifications . data . indexOf ( notification ) ;
202196 if ( index !== - 1 ) {
203197 notifications . removeIndex ( index ) ;
204198 }
205199 } ;
206200
207201 notifications . removeIndex = function ( index ) {
208- $rootScope . notifications . remove ( index ) ;
202+ //notifications.remove(index);
203+ notifications . data . splice ( index , 1 ) ;
209204 } ;
210205
211206 notifications . setViewing = function ( notification , viewing ) {
@@ -215,20 +210,18 @@ angular.module('patternfly.notification').provider('Notifications', function ()
215210 }
216211 } ;
217212
218- notifications . data = $rootScope . notifications . data ;
219-
220213 return notifications ;
221214 } ] ;
222215
223216} ) ;
224217
225218/**
226219 * @ngdoc directive
227- * @name patternfly.notification.directive :pfNotificationList
220+ * @name patternfly.notification.component :pfNotificationList
228221 * @restrict E
229222 *
230223 * @description
231- * Using this directive automatically creates a list of notifications generated by the {@link api/patternfly.notification.Notification notification} service.
224+ * Using this component automatically creates a list of notifications generated by the {@link api/patternfly.notification.Notification notification} service.
232225 *
233226 * @example
234227 <example module="patternfly.notification">
@@ -298,16 +291,14 @@ angular.module('patternfly.notification').provider('Notifications', function ()
298291
299292 </example>
300293 */
301- angular . module ( 'patternfly.notification' ) . directive ( 'pfNotificationList' , function ( ) {
302- 'use strict' ;
303-
304- return {
305- restrict : 'E' ,
306- controller : NotificationListController ,
307- templateUrl : 'notification/notification-list.html'
308- } ;
309-
310- function NotificationListController ( $scope , $rootScope ) {
311- $scope . notifications = $rootScope . notifications ;
294+ angular . module ( 'patternfly.notification' ) . component ( 'pfNotificationList' , {
295+ templateUrl : 'notification/notification-list.html' ,
296+ controller : function ( Notifications ) {
297+ 'use strict' ;
298+ var ctrl = this ;
299+
300+ ctrl . $onInit = function ( ) {
301+ ctrl . notifications = Notifications ;
302+ } ;
312303 }
313304} ) ;
0 commit comments