Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using $implict to pass multiple parameters

Tags:

I have a template to be recursive, something similar to below:

<ng-container *ngTemplateOutlet="testTemplate; context: {$implicit:jsonObj1}"> </ng-container>  <ng-template #testTemplate let-Json1> </ng-template> 

It works fine, I send jsonObj1 using $implicit, but I would like to send two parameters to , if I try:

context: {$implicit:jsonObj1, $implicit:jsonObj2} 

and try to access using

<ng-template #filterTemplate let-Json1 let-json2> </ng-template> 

It doesn't work, let me know, how to pass two parameters.

like image 772
Michael Philips Avatar asked Jan 30 '18 14:01

Michael Philips


1 Answers

You don't need to use $implicit

You can use

1:

context: {$implicit:jsonObj1, b:jsonObj2} 

with

<ng-template #filterTemplate let-json1 let-json2="b">   <div>{{json1}}</div></div>{{json2}}</div> </ng-template> 

or 2:

context: {$implicit: {a: jsonObj1, b:jsonObj2}} 

with

<ng-template #filterTemplate let-json1>   <div>{{json1.a}}</div></div>{{json1.b}}</div> </ng-template> 

or 3:

context: {a:jsonObj1, b:jsonObj2} 

with

<ng-template #filterTemplate let-json1="a" let-json2="b">   <div>{{json1}}</div></div>{{json2}}</div> </ng-template> 
like image 139
Günter Zöchbauer Avatar answered Oct 21 '22 23:10

Günter Zöchbauer