Possibility to add class="" using <ng-content>
See original GitHub issueFeature Request
Description
Currently the ng-content tag is just a placeholder that will be replaced. When creating eg. a component library we might get code that is encapsulated and not easily styled by the library consumers.
eg.
<ng-content select="header"></ng-content>
<div class="content">
<div class="body">
<ng-content></ng-content>
</div>
</div>
in this case the body class has a padding and to be able to change that padding library consumer need to use something like ::ng-deep.
Describe the solution you’d like
Something like this perhaps?
<ng-content select="header"></ng-content>
<ng-content class="content" select="content">
<ng-content class="body" select="body">
</ng-content>
</ng-content>
and the classes would be merged… This would allow ui component creator to have default styling and also make it easier to the consumers of the component to add styling 😃
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Custom Styling on <ng-content> in angular2 not working
According to the web components spec ::content should be enough and >>> should not be required but the styles were not applied without...
Read more >Angular ng-content and Content Projection: A Complete Guide ...
So let's implement a small component without using content ... the input is simulated by adding a focus css class to the host...
Read more >Components-constructors: the power of ng-content in Angular
We can have several ng-content s in one template and choose between them with select attribute. It takes any CSS selector: element name,...
Read more >ng-content in Angular - GeeksforGeeks
The ng-content is used when we want to insert the content dynamically inside the component that helps to increase component reusability. Using ......
Read more >Using ng-content for Content Projection - DEV Community
To solve this, ng-content has a property named select . If you specify select with a CSS matching selector, it will get only...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @indraraj26 , Thanks for example. The problem in example is you are using
But element with body class is not parent of
.child-content
, it is sibling. I changed it toand it worked.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.