Can't bind to 'ngTemplateOutletContext' since it isn't a known property of 'ng-container'.

Dung Do Tien Jan 28 2021 279

 I have built the project with angular 11  and getting the following error when working with ngTemplateOutletContext

Can't bind to 'ngTemplateOutletContext' since it isn't a known property of 'ng-container'.

Any idea how to handle?

Have 1 answer(s) found.
  • H

    Huyền Trần thị Jan 27 2021

    Here is the correct syntax, when you want to send the dynamic data to ng-template as input/variable using ngTemplateOutletContext like 

     <ng-container [ngTemplateOutlet]="templateName"
          [ngTemplateOutletContext]="{$implicit: 'Hi', object: 'abcxyz}">
    </ng-container>
    
    <ng-template #templateName let-default let-object="object">
    
      {{default}}
    
      {{object}}
    
    </ng-template>

    Hope resolve for you!

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close