1

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.

balaG
  • 431
  • 1
  • 8
  • 16

1 Answers1

1

<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>

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • I have update the plunker code and now ng-content is not in the root – balaG Nov 21 '16 at 20:54
  • But there is also nothing matching the selectors. It's still entirely unclear what your question is about. What is the expected behavior? – Günter Zöchbauer Nov 21 '16 at 20:55
  • @GünterZöchbauer Hi. I used `` in root in a project and it works, but now I can't do that in a new project and I can't understand where's the problem. Could you help me? This is the link to my question: https://stackoverflow.com/questions/52388854/why-is-angular-transclusion-ignored-in-app-root – erikscandola Sep 18 '18 at 15:18