balaG
balaG

Reputation: 461

Angular 2 Ng-Content and it seems not working

I am trying to use Ng-Content and it seems not working. The full code is here in plunker Full code

@Component({
  selector: 'my-app',
  template: `
    <div>
      <h2>Hello {{name}}</h2>
      <div>
        Title:
        <ng-content select=".my-component-title"></ng-content>
      </div>
      <div>
        Content:
        <ng-content select=".my-component-content"></ng-content>
      </div>
    </div>
  `,
})

I have updated the plunker code and now the ng-content is not at the root component. But still its not working.

Upvotes: 1

Views: 2279

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657118

<ng-content> on the root component is not supported.

<ng-content> only transcludes elements and components defined in an Angular2 component.

See also Angular2 root component with <ng-content>

Upvotes: 1

Related Questions