-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BodyOutputType.Component throws No component factory found for DynamicComponent #84
Comments
Thank you for the detailed steps to reproduce. There's a lot going on here and the majority of it has to do with how Angular 2 locks down DOM rendering as a security precaution. Let me walk through a few of the issues first before discussing the solution. First, Ok, so TrustedHtml is out...what about So what does this mean? While it is a bit heavy, you would need to create a new component that imports I've created a detailed plunker for you that describes how to do this. While you do not need to wrap your component in an ngModule, it is usually common to do so for reusable modules and I wanted the example to be as complete as possible. Please ensure that you are using I am closing this issue since it is a usability question, not a bug, but if you need additional help or direction, please feel free to continue the dialog on this issue. |
@Stabzs Thank you very much - that is really helpful! So at the moment I now have a working example based on your plunker. it binds I want to be able to access both the notification title and the value of my input, in the same component. I cannot see how to access the notification title from the child (NotificationBody) component. I looked at the
in my console. Is it possible to use this (or another approach) to get to the value of answer for each notification? |
You're welcome! Are you able to create a plunker demonstrating your progress so far based off of the one I provided? That would help mu understand the data relationships. |
@georgeedwards perhaps the most explicit way would be to use a shared service. This allows you to encapsulate all of your logic around the answer in one place. Using rxjs Subscriptions will allow you to push and retrieve data. I'd also recommend passing along any relevant toast information as well so that you can identify the source. |
Awesome - that works well. I had to remove |
@georgeedwards ahh, whoops, thanks for cleaning that up :). Your final question is a tricky one...because of the nature of dynamically loaded components created via ComponentFactoryResolver, an I may need to look at enhancing dynamically loaded components with the toast id at creation so that they are always available. I'll look into this a bit more. |
@Stabzs Awesome - thank you! That would be a really helpful enhancement. |
@Stabzs If there is anything I can do to help - please give me a shout! |
@georgeedwards I apologize, I haven't had time to release this improvement. I am currently looking at it. |
When rendering BodyOutputType.Component, the toast instance itself is applied to the rendered component. This allows the component to interact with the toast as needed, as well as expose access to the toast id. Addresses #84. ResetTimer on mouseout was not being properly called. It is now called appropriately when mouseoverTimerStop is set to true. Thanks to @kb3eua for the pull request fix. Documented the mouseoverTimerStop config option and documented the addition of the toast instance to components when using BodyOutputType.Component. Closes #83.
This is now published under package |
@georgeedwards I've also updated the previous plunker to use a an object response wrapper in the shared service that passes the toast id from the instance, using version |
I am trying to use a component for the body of a toast - like this:
However, this throws error:
Why?
The text was updated successfully, but these errors were encountered: