#ng-content and contentChildren

5 messages · Page 1 of 1 (latest)

deep ravine
#

would you mind sharing the stackblitz?

old vector
#

contentChildren(".myClass"); is not correct. If you pass a string to contentChildren (let's say 'foo'), then it looks for elements in the projected content marked with a template variable named foo, i.e. something like <div #foo>.
Also, you can't project several different things with ng-content.

minor jetty
#

I'm not sure about what do u want to do properly but do you have a root inner DOM? If yes, you could use:

@Component({
selector: 'upper',
template: <ng-content></ng-content>
})
export class UpperComponent {
@Input
content: String;

@ContentChild(...)
element: any;
}

minor jetty
#

I hope you can do it. Good afternoon.