-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
@ContentChildren with descendants search provided by directive doesn't work if used for ng-content #14320
Comments
|
@DzmitryShylovich I doubt that this is duplicate. In #12758 issue caused by class inheritance was mentioned. There is no class inheritance in my case and component class to select by ContentChildren is defined explicitly |
This is clear. I used ViewChild decorator to get the instance of my directive in both cases: in the template of container component and in the template of the app component. And instance of the directive was received successfully: there is no issuse with this. Issue is that ContentChildren @ContentChildren(MyInput, { descendants: true }) private inputComps: QueryList<MyInput>; which was used in directive to query the list of my "input" doesn't work in case when I place directive in template of my container component, but works when I use directive in template of app component |
http://prntscr.com/e56ocv vs http://prntscr.com/e56on8
|
What you want is described here #8563 |
Here is another case: I used "select" directive in the template and also defined ContentChildren in template ( plunker ): @Component({
selector: 'my-container',
template: `
<div inputFinder>
<ng-content></ng-content>
</div>
<p>
<button (click)="dumpInputs()">DUMP INPUTS</button>
</p>
`
})
export class MyContainer {
@ViewChild(InputFinderDirective) inFinder: InputFinderDirective;
@ContentChildren(MyInput, { descendants: true }) private inputComps: QueryList<MyInput>;
dumpInputs() {
console.log('Inputs selected by directive: ', this.inFinder.getInputs());
console.log('Inputs selected by container component: ', this.inputComps.toArray());
}
} And list selected by directive is empty. At the same time list selected by component is proper. Same ContentChildren metadata was used in both cases. |
queries components here http://prntscr.com/e5741e
queries components here http://prntscr.com/e574j5 To me it works as intended |
Hi @mhevery can you pls comment whether this issue ( plunker ) is related to the dynamic content projection or not. |
I am a bit confused what you think the bug is. One can not query across a Here is the working plunker when I change it to |
@andrui did he answer your question? can this be closed? |
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. |
Hi,
Use-case:
Here is plunker with STR:
The text was updated successfully, but these errors were encountered: