In this article, we will learn how to project content in an Angular Element. If you are unfamiliar with the following, Shadow Dom ViewEncapsulation Content Projection I recommend you read the articles below before moving forward: Understanding ViewEncapsulation in Angular Simplifying Content Projection in Angular As of now, you know that we use ng-content to carry out content projection as shown in the next listing: You can also project content as shown in the next listing: The challenge with the above approach is, "If you use GreetComponent as your Angular Element," you will not able to project content. To understand this better, let us start with converting GreetComponent to an Angular Element. Here you can Learn Step by Step tp Create Angular Element. After converting GreetComponent as Angular Element, AppModule should look like the listing below: Now you can use GreetComponent on index.html as shown in the listing below: Upon running the application, you will find that the element has not been projected to the Angular Element GreetComponent.
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
angular,Angular 7,Contnet Projection,slot
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
angular,Angular 7,Contnet Projection,slot
No comments:
Post a Comment