Questions tagged [angular2-ngcontent]
94 questions
1
vote
0 answers
How to pass data through ng-content?
My goal is to select a piece of HTML in component 2 which should render HTML with data from component 1.
This is the demo pseudo code of my aproach:
Component 1

Elkin
- 880
- 2
- 12
- 26
1
vote
4 answers
Apply CSS Style inside ng-content
in an Angular application I have a component with . I added the scss rules for content that will be put inside the ng-content, but they are ignored. I tried to solve using :host, but it doesn't…

panagulis72
- 2,129
- 6
- 31
- 71
1
vote
0 answers
Not able to use Transclusion in ng-content using angular6
i am trying to build dynamic tabs, so i decided to use the Transclusion approach of ng-content but i am not able to get the object from the ngFor loop. this is my code
1
vote
1 answer
How do I conditionally wrap multiple times?
I tried writing a wrapper component which can be passed some text and some parameters, which would then format my text using bootstrap, based on these parameters.
I've tried this:
header-line.component.ts
@Component({
selector:'header-line',
…

Urs Beeli
- 746
- 1
- 13
- 30
1
vote
3 answers
Angular template and transclusion: content out of order
I'm facing some challenges with Angular content projection.
I have a template that has some common HTML for every instance that will be used, and another part that will be subject to change from case to case, via transclusion (ng-content).
The…

NunoM
- 293
- 3
- 17
1
vote
2 answers
Angular transclusion when using multiple components
I have three components of following hierarchy:
Im confused on how to pass a component from to component Via…

StangSpree
- 421
- 1
- 5
- 22
1
vote
2 answers
*ngFor without wrapping inside ng-content
I need to repeat a component inside another component, let's say:
Component A only accepts, inside its ng-content, a component of type B.
doing something like:
…

Sergio Figueiredo
- 71
- 1
- 6
1
vote
2 answers
*ngFor on elements of ng-content Angular
I was wondering if is it possible to create a iteration of certain elements of . I need a different css class to every element of the ng-content so i need to make a loop of every element of ng-content. Is it possible?
Right now i pass a parameter to…

Hely Saul Oberto
- 577
- 1
- 10
- 22
1
vote
1 answer
Angular: ViewContainer isn't inserting component adjacent to anchor element, but nesting within the component itself
I have created a tab view, with the following structure:
…
- tab1
- tab2

Erik R
- 201
- 1
- 15
1
vote
0 answers
bootstrap panel not taking the ng-content
I'm new to angular and trying to listing a bootstrap panel in a typescript page.
so I'm trying to do it like this
bootstrap.panel.component.ts
import {Component} from 'angular2/core';
@Component({
selector: 'bs-panel',
template: `

Kelum
- 1,745
- 5
- 24
- 45
1
vote
1 answer
Angular 4 + primeng : pass HTML content from a component to another
I want to add some server-side pagination functions to the primeng datatable (p-datatable) in multiple places so I declared a new component "pagin-datatable.component" with the functions and behavior I need.
So pagin-datatable.component.html…

Callehabana
- 95
- 2
- 14
1
vote
2 answers
Angular 2- ContentChidren of parent component are undefined when dynamically creating child component
I've been trying to make a tab view and thought content projection might be a good approach.I learned it from this article. I thought that I could make it dynamic by just inputting a given array of components, and they would be displayed as the page…

Erik R
- 201
- 1
- 15
1
vote
0 answers
Dynamically add components to tabs angular 2
The goal is to dynamically load components from a list and display them with their associated tab.
My approach for making tabs is a based off of the this tutorial: https://juristr.com/blog/2016/02/learning-ng2-creating-tab-component/ and
This…

Erik R
- 201
- 1
- 15
1
vote
0 answers
Angular ng-content with input inside an *ngFor
I'm trying to build a component in Angular which can render different components inside; it will be like a dynamic table, so when a user clicks on the row it expands to display something; that something depends and ideally will be anything.
So, I'm…

David
- 3,364
- 10
- 41
- 84
1
vote
3 answers
In angular2, how can I detect is there any ng-content?
plnkr demo here
@Component({
selector: 'my-demo',
template: `This is `
})
export class DemoComponent { name = 'Angular'; }
@Component({
selector: 'my-app',
template: `
Hello {{name}}
…
wener
- 7,191
- 6
- 54
- 78