Reputation: 642
I'm in situation where I have a 'Items' component that has ng-content:
@Component({
selector: 'items'
template: `<ng-content></ng-content>`
})
I would like to get the value of this content, so that's why I'm using ContentChildren where I passed my 'Item' directive as selector.
@ContentChildren(Item) elements: QueryList<Item>;
Unfortunately I can't get any data.
Here I attach a link to plunker
In elements property I would like to have all elements from 'App' component that I've marked with 'Item' directive.
<items>
<div item *ngFor="let num of nums">{{ num }}</div>
</items>
Am I doing something wrong?
Upvotes: 3
Views: 857
Reputation: 214047
You have wrong selector for Item component. It should be
[item]
because you use it as attribute
Upvotes: 3