Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

How to access THREE object inside a ng-template/ng-container #89

Answered by nartc
IRobot1 asked this question in Q&A
Discussion options

You must be logged in to vote

@IRobot1 Gotcha. So that's how Angular Content Projection works (I hate it)

<ngt-group>
   <ngt-mesh> <!-- this is fine, the Mesh can find the Group as its parent -->


<content-button> <!-- this wraps the ngt-group -->
   <ngt-mesh> <!-- Angular does not give this Mesh the inner Group injector :( -->

To get around this (as a feature, not a workaround 😅), is to adjust your content-button a little bit

@Component({
   template: `
      <ngt-group #ngtGroup="ngtGroup">
         <ng-container *ngIf="content" [ngTemplateOutlet]="content" [ngTemplateOutletContext]="{ parent: ngtGroup.group }"></ng-container>
      </ngt-group>
      <ng-content></ng-content>
   `,
})
export class ContentButton {

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@IRobot1
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by IRobot1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants