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
Nested ng-content with selector doesn't get content #21550
Comments
Where did you find that it should work this way? |
As @alexzuza mentioned above, it works as designed and you also get it right in your plunker: what you want to re-project is the That being said, your use case is legit and there is a little known Angular construct for that: the @Component({
selector: 'my-wrapper-component',
template: `
<my-component>
<ng-content select="input" ngProjectAs="input"></ng-content>
</my-component>
`
})
export class MyWrapperComponent {
} |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a...
Current behavior
I have two components:
When the outer component is used with content, the content doesn't project, i.e. what I write is
which results in the following DOM:
If we modify the
<ng-content select="input">
in theInnerComponent
to<ng-content select="input, ng-content">
, it does output the correct DOM:however we lose the fact that we only want
input
elements so this doesn't work when projecting multiple elements to differentng-content
s.Expected behavior
It should result in the correct DOM without workaround.
Minimal reproduction of the problem with instructions
http://plnkr.co/edit/GKaUMGTpI2K8BukQI6co?p=preview
What is the motivation / use case for changing the behavior?
I'm building a library of complex input components (e.g. input masks …) and I want the consumer of the library to provide the actual
<input>
element so they can control the placeholder, tabindex and aria attributes. Right now run into this because the date input in my library uses the input mask internally:I can use the workaround for now, until I run into a component that needs multiple content projections.
Environment
The text was updated successfully, but these errors were encountered: