Skip to content

Feature proposal: Allow to pass in a templateRef #94

@juristr

Description

@juristr

Hi,

I'm looking at your implementation of notifications in Angular and really like your clean code. I was thinking about extending it, allowing for some more heavy customization. In my case, I cannot really use your material style as it doesn't go well together with the Clarity design system style which is used by the app I'm working on. I would need something that looks more like this:

image

Still I'd like to make use of your animation, stacking behavior etc. The idea would be to allow to also pass a template reference to the NotifierService, something like

export class SomeComponent {
   ...
   @ViewChild('notificationTmpl) notificationTmpl;

   showNotification() {
      this.notifier.show({
        message: msg.message,
        type: msg.messageType,
        template: this.notificationTmpl
      });
   }

Inside the notifier-notification.component

https://github.com/dominique-mueller/angular-notifier/blob/1e26507667a7f0f4013d9d6ade8d75186b2a5b50/src/lib/src/components/notifier-notification.component.html#L1-L7

...I'd then check whether that template has been defined. If it has, then instantiate it there, passing to it the details about the message etc, and if not, just fallback to the current behavior.

What do you think about this? It would really allow to heavily customize the notifications, allowing for icons and whatever the user wants, still taking benefit from the whole logic you've already implemented 😄. I can provide a PR for this

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: featureIndicates a feature or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions