How to access a component property inside ng-template inside another component?

Viewed 378

I'd like to know how to access a component property when the component is inside an ng-template and is also inside a component content. Like this:

<app-foo [num]="comp.num">
  <ng-template>
    <!-- Doesn't work -->
    <app-one ref-comp></app-one>
  </ng-template>

<!-- Works -->
  <app-one ref-comp></app-one>
</app-foo>

I've created a minimal stackblitz here: https://stackblitz.com/edit/angular-ivy-yxeknr?file=src/app/app.component.html

My requirements is that app-one will stay inside ng-template and that the ng-template will be inside app-foo

I also don't want to use ViewChild to get app-one as I may have mutliple app-num components (app-one, app-two,..).

1 Answers
Related