Hi As far as I know, it is relevant to use ViewContainerRef now. But it can be inconvenient because only Component and Directive can inject it. For example, we won't be able to use it normally in a service unlike ComponentFactoryResolver. Perhaps you know other alteratives?
All these tips are making me better everyday. Can you make a tutorial on how we can use Angular/typescript to (1) detect device theme(light or dark) and adapt to that, (2) an option to switch themes manually. I usually just use vanilla javascript and css to achieve this even in my angular projects.
The deprecated ComponentFactoryResolver can be replaced by ViewContainerRef. In the constructor private viewContainerRef: ViewContainerRef, In the onMouseEnter this.tooltipComponent = this.viewContainerRef.createComponent(TooltipComponent);
I have written the same code, but on mouse enter it appends the tooltip component to the body but it is not getting displayed. Please help me out with this.
WATCH NEXT: Angular Unit Testing Course - All That You Need to Know About Testing - ua-cam.com/video/bv9z_UfSqgM/v-deo.htmlsi=WVzOWtdQUZWEbqsz
This video is pure gold! Thank you!
You are welcome!
the best teacher!!!
Thank you!
As always, a very informative tutorial. 👍 FYI ComponentFactoryResolver for dynamic component creation has been deprecated since v13.
Hi
As far as I know, it is relevant to use ViewContainerRef now.
But it can be inconvenient because only Component and Directive can inject it. For example, we won't be able to use it normally in a service unlike ComponentFactoryResolver.
Perhaps you know other alteratives?
All these tips are making me better everyday. Can you make a tutorial on how we can use Angular/typescript to (1) detect device theme(light or dark) and adapt to that, (2) an option to switch themes manually. I usually just use vanilla javascript and css to achieve this even in my angular projects.
That would be very useful!
Thank you for the idea. I will add it to the list.
@@MonsterlessonsAcademy looking forward to it.
this is very helpful, thanks ☺
You're welcome 😊
good video, but I couldn't use ComponentFactoryResolver in my project (Abgular 14)
- this class is already depricated
component class can be used directly with ViewContainerRef.createComponent()
exactly
The deprecated ComponentFactoryResolver can be replaced by ViewContainerRef.
In the constructor
private viewContainerRef: ViewContainerRef,
In the onMouseEnter
this.tooltipComponent = this.viewContainerRef.createComponent(TooltipComponent);
I have written the same code, but on mouse enter it appends the tooltip component to the body but it is not getting displayed. Please help me out with this.
make a class and add: position: absolute;
ComponentFactoryResolver is deprecated...
stellar
Good stuff
Thank you!
Would be a great idea, if in the tooltip we could add HTML...
For example an icon and a message🙂
You could extend the idea and pass a TemplateRef with any html you wish.
You can look on this video. We render modal in body with custom template
ua-cam.com/video/MuHpsz7Q3P0/v-deo.html
since v16 ComponentFactoryResolver has been removed
Even earlier. Check how to do it now
stackoverflow.com/questions/70946038/replace-deprecated-angular-componentfactoryresolver-componentfactory
You can use [style.left.px]=“left” to avoid ugly string concat ))