question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature proposal: Allow to pass in a templateRef

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
juristrcommented, Aug 3, 2018

👍 Alright, PR coming soon

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pass different context to ngIf - Stack Overflow
Do you agree there's some benefit in proposing a feature to allow context to be passed via microsyntax as I've outlined in the...
Read more >
ngTemplateOutlet: The secret to customisation - Angular inDepth
Let's start by introducing our component code and then start adding new features. ... To pass context to a template you use [ngTemplateOutletContext]...
Read more >
How to pass a custom template to an Angular component?
Solution #2: Passing templates around with ng-template and ng-container. Angular allows us to wrap some HTML within an ng-template tag like so: <ng-template>...
Read more >
TemplateRef - Angular
Access a TemplateRef instance by placing a directive on an <ng-template> element (or directive prefixed with * ). The TemplateRef for the embedded...
Read more >
Composition API FAQ - Vue.js
Composition API is a set of APIs that allows us to author Vue components using ... a language feature that was only a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found