0

Currently, I have ng-template defined as below which works well, but I wanted to have the let variable defined with dynamic value, can you please help me how to solve this problem?

Working

<ng-template #topTemplate ng-label-tmp let-item="item" let-clear="clear"
  aria-autocomplete="none" let-insideSubItemTop="item.parent.name">
  
  <div class="badge badge-pill df-closable badge-blue">
    {{insideSubItemTop}}
    <button type="button" [badgeEventListener]="[clear, item]">
      <span aria-hidden="true" class="icon-times"></span>
    </button>
  </div>

</ng-template>

But I wanted to define the value in ng-template based on the computation done in the component.ts

Not Working

let-insideSubItemTop="{{computedInComponent}}"

So I tried in my component.ts with computedInComponent = 'item.parent.name';

The above is not working, can some help me how to achieve this?

Vítor França
  • 687
  • 6
  • 19
Mahesh G
  • 1,226
  • 4
  • 30
  • 57
  • Does this answer your question? [Pass variable in Angular 2 template](https://stackoverflow.com/questions/43726749/pass-variable-in-angular-2-template) (+ https://angular.io/api/common/NgTemplateOutlet#properties) – Philipp Meissner Nov 28 '21 at 15:41
  • how are you using your template? is it `ngTemplateOutlet`? – Andrei Nov 28 '21 at 22:09

0 Answers0