diff --git a/README.md b/README.md index c22ff68..bbf7089 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,23 @@ You could also pass the template through the `open()` method: } ``` +You can pass arbitrary data to your template: +```html + +

{{ text }}!

+
+``` +```ts + @ViewChild('example') example: TemplateRef; + + open() { + this._service.success(this.example, null, { + templateData: {text: 'hi'}, + }); + } +``` + + ## Subscribing to clicks If you are interested in the clicks that happen on a notification you have the possibility to subscribe to a EventEmitter. The methods (success, error, alert, warn, info, warn, bare, create and html) from the diff --git a/src/components/notification/notification.component.html b/src/components/notification/notification.component.html index 641c644..1260287 100644 --- a/src/components/notification/notification.component.html +++ b/src/components/notification/notification.component.html @@ -17,30 +17,39 @@
- + +
-
+
- + +
-
+
- + +
-
+
diff --git a/src/components/notification/notification.component.ts b/src/components/notification/notification.component.ts index adc0df7..eb9d29a 100644 --- a/src/components/notification/notification.component.ts +++ b/src/components/notification/notification.component.ts @@ -126,9 +126,8 @@ export class NotificationComponent implements OnInit, OnDestroy { // Progress bar variables - public title: any; - public content: any; + public templateData: any = null; public titleIsTemplate = false; public contentIsTemplate = false; public htmlIsTemplate = false; @@ -250,12 +249,6 @@ export class NotificationComponent implements OnInit, OnDestroy { } private contentType(item: any, key: string) { - if (item instanceof TemplateRef) { - this[key] = item; - } else { - this[key] = this.domSanitizer.bypassSecurityTrustHtml(item); - } - this[key + 'IsTemplate'] = item instanceof TemplateRef; } }