Questions tagged [angular2-ngcontent]

94 questions
6
votes
1 answer

reference component variable from ng-content

I have the following piece of markup:
{{'PRICE' | resource}}
group-header's template looks like this:
CJe
  • 1,928
  • 3
  • 24
  • 53
5
votes
3 answers

Angular2+ render a component without any wrapping tag at all

My child-component looks like: ... @Component({ selector: '[child-component]' templateUrl: './child.template.html' }) ... and my parent template like: now I want to render the content of my…
5
votes
1 answer

ng-content in for loop

I'm trying to create a tab component using bootstrap. Description 1 Description 2 I had a look at this…
Breno
  • 53
  • 1
  • 1
  • 4
5
votes
2 answers

Angular 4 ngComponentOutlet loads dynamic components, but route content is not being rendered

I'm trying to load different 'parent' components and inject route content into these different parent components by targeting ng-content in each parent component. Essentially, each parent component handles the navigation and other boilerplate stuff…
Tom Schreck
  • 5,177
  • 12
  • 68
  • 122
5
votes
1 answer

Passing property to components inside ng-content (properties which aren't available in the component where the markup lies)

I am trying to develop a carousel. The desired end result should be that the developer would simply write the entire markup in one place (let's say in app.component.html) with only an options property and then, the carousel would take over. Problem…
MrCroft
  • 3,049
  • 2
  • 34
  • 50
5
votes
1 answer

Angular2 @ContentChildren not populated inside parent

ISSUE: @ContentChildren does not seem to work on Parent containers. Even if the content is a child of the component. Plunker: https://plnkr.co/edit/J5itJmDfwKwtBsG6IveP?p=preview NOTE: I Am using {descendants: true} Example Code: Main…
Kevin Upton
  • 3,336
  • 2
  • 21
  • 24
5
votes
1 answer

Can I 'observe' the dynamic children of a component?

I have an application in which I compose forms using several form components. Now I want to create some kind of a foreign key field which lists the already existing objects and also shows an 'add' button. This button displays another form component…
Johan
  • 390
  • 4
  • 11
5
votes
1 answer

ngIf=false with ngContent still loads template bindings

Defining a simple component as follows: @Component({ selector: 'loader', template: `
`, }) export class Loader {} When using it like this: {{model.something}} …
David
  • 15,652
  • 26
  • 115
  • 156
4
votes
1 answer

How to loop through section elements to project with ng-content

I'm building a stepper and am using "transclusion" with ng-content to dynamically grab section elements within the stepper tag. The stepper.component view works like this:
Ben Racicot
  • 5,332
  • 12
  • 66
  • 130
4
votes
1 answer

How to select content from inner children in ng-content

I have a component called tab which has Sometimes tabItem is inside other child components. My problem is Angular selects the content from direct children, not inner children (app-my-tab), is there any…
Reza
  • 18,865
  • 13
  • 88
  • 163
4
votes
2 answers

Angular 2 ng-content receive event from child component

I am building a page with several dynamic panels, each child panel has the same HTML so I have created a parent panel component to wrap each one. The problem is I want to send an event from the child to the panel but I cant seem to find an answer.…
EJP
  • 181
  • 4
  • 13
4
votes
5 answers

Access parent component from child component when parent component using ng-content Angular

I'm trying to access parent component from child component using dependence injection. It works, I can access to parent to using its methods and properties but I have not seen this approach on Angular doc. So do you have any idea about this…
Nguyen Tran
  • 1,158
  • 1
  • 11
  • 18
3
votes
1 answer

Angular pass template reference using ng-content

I want to pass ng-template as ng-content nested inside child app-component.html
this should be passed to grand child
3
votes
0 answers

Angular ng-content n first element

Hi I'm trying to split the content of a component in two parts and I can't seems to make it work. I know that I can user ng-content with the attribute select but I don't know if it's possible to select a number of element with it. I have this…
3
votes
1 answer

Is deep ng-content select possible at all?

Suppose I want to transclude such a markup into ng-content:
AAA
BBB
For this I can use selectors (which look like regular CSS ones): ----- some other content here…