55 EventEmitter ,
66 ComponentRef ,
77 ViewChild ,
8- OnInit ,
98 HostBinding
109} from "@angular/core" ;
1110
@@ -48,7 +47,7 @@ import { I18n } from "./../i18n/i18n.module";
4847 ` ,
4948 providers : [ NotificationService ]
5049} )
51- export class Notification implements OnInit {
50+ export class Notification {
5251 /**
5352 * Can have `type`, `title`, and `message` members.
5453 *
@@ -57,7 +56,12 @@ export class Notification implements OnInit {
5756 * `message` is message for notification to display
5857 *
5958 */
60- @Input ( ) notificationObj : NotificationContent ;
59+ @Input ( ) get notificationObj ( ) : NotificationContent {
60+ return this . _notificationObj ;
61+ }
62+ set notificationObj ( obj : NotificationContent ) {
63+ this . _notificationObj = Object . assign ( { } , this . defaultNotificationObj , obj ) ;
64+ }
6165
6266 /**
6367 * Emits on close.
@@ -80,13 +84,15 @@ export class Notification implements OnInit {
8084 @HostBinding ( "class.bx--inline-notification--success" ) get isSuccess ( ) { return this . notificationObj . type === "success" ; }
8185 @HostBinding ( "class.bx--inline-notification--warning" ) get isWarning ( ) { return this . notificationObj . type === "warning" ; }
8286
83- constructor ( protected notificationService : NotificationService , protected i18n : I18n ) { }
87+ protected defaultNotificationObj = {
88+ title : "" ,
89+ message : "" ,
90+ type : "info" ,
91+ closeLabel : this . i18n . get ( ) . NOTIFICATION . CLOSE_BUTTON
92+ } ;
93+ protected _notificationObj : NotificationContent = Object . assign ( { } , this . defaultNotificationObj ) ;
8494
85- ngOnInit ( ) {
86- if ( ! this . notificationObj . closeLabel ) {
87- this . notificationObj . closeLabel = this . i18n . get ( ) . NOTIFICATION . CLOSE_BUTTON ;
88- }
89- }
95+ constructor ( protected notificationService : NotificationService , protected i18n : I18n ) { }
9096
9197 /**
9298 * Emits close event.
0 commit comments