@@ -103,6 +103,7 @@ angular.module('patternfly.notification').provider('Notifications', function ()
103
103
this . delay = 8000 ;
104
104
this . verbose = true ;
105
105
this . notifications = { } ;
106
+ this . notifications . data = [ ] ;
106
107
this . persist = { 'error' : true , 'httpError' : true } ;
107
108
108
109
this . setDelay = function ( delay ) {
@@ -119,7 +120,7 @@ angular.module('patternfly.notification').provider('Notifications', function ()
119
120
this . persist = persist ;
120
121
} ;
121
122
122
- this . $get = [ '$rootScope' , '$ timeout', '$log' , function ( $rootScope , $timeout , $log ) {
123
+ this . $get = [ '$timeout' , '$log' , function ( $timeout , $log ) {
123
124
var delay = this . delay ;
124
125
var notifications = this . notifications ;
125
126
var verbose = this . verbose ;
@@ -132,15 +133,8 @@ angular.module('patternfly.notification').provider('Notifications', function ()
132
133
warn : { type : 'warning' , header : 'Warning!' , log : 'warn' }
133
134
} ;
134
135
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 = [ ] ;
144
138
}
145
139
146
140
notifications . message = function ( type , header , message , isPersistent , closeCallback , actionTitle , actionCallback , menuActions ) {
@@ -156,7 +150,7 @@ angular.module('patternfly.notification').provider('Notifications', function ()
156
150
} ;
157
151
158
152
notification . show = true ;
159
- $rootScope . notifications . data . push ( notification ) ;
153
+ notifications . data . push ( notification ) ;
160
154
161
155
if ( ! notification . isPersistent ) {
162
156
notification . viewing = false ;
@@ -198,14 +192,15 @@ angular.module('patternfly.notification').provider('Notifications', function ()
198
192
} ;
199
193
200
194
notifications . remove = function ( notification ) {
201
- var index = $rootScope . notifications . data . indexOf ( notification ) ;
195
+ var index = notifications . data . indexOf ( notification ) ;
202
196
if ( index !== - 1 ) {
203
197
notifications . removeIndex ( index ) ;
204
198
}
205
199
} ;
206
200
207
201
notifications . removeIndex = function ( index ) {
208
- $rootScope . notifications . remove ( index ) ;
202
+ //notifications.remove(index);
203
+ notifications . data . splice ( index , 1 ) ;
209
204
} ;
210
205
211
206
notifications . setViewing = function ( notification , viewing ) {
@@ -215,20 +210,18 @@ angular.module('patternfly.notification').provider('Notifications', function ()
215
210
}
216
211
} ;
217
212
218
- notifications . data = $rootScope . notifications . data ;
219
-
220
213
return notifications ;
221
214
} ] ;
222
215
223
216
} ) ;
224
217
225
218
/**
226
219
* @ngdoc directive
227
- * @name patternfly.notification.directive :pfNotificationList
220
+ * @name patternfly.notification.component :pfNotificationList
228
221
* @restrict E
229
222
*
230
223
* @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.
232
225
*
233
226
* @example
234
227
<example module="patternfly.notification">
@@ -298,16 +291,14 @@ angular.module('patternfly.notification').provider('Notifications', function ()
298
291
299
292
</example>
300
293
*/
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
+ } ;
312
303
}
313
304
} ) ;
0 commit comments