使用$ implict传递多个参数 [英] Using $implict to pass multiple parameters
本文介绍了使用$ implict传递多个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个递归模板,类似于以下内容:
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>
它工作正常,我使用$ implicit发送jsonObj1,但是如果尝试尝试的话,我想将两个参数发送给:
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}
,然后尝试使用
<ng-template #filterTemplate let-Json1 let-json2>
</ng-template>
让我知道如何传递两个参数是行不通的.
It doesn't work, let me know, how to pass two parameters.
推荐答案
您不需要使用$implicit
您可以使用
1:
context: {$implicit:jsonObj1, b:jsonObj2}
与
<ng-template #filterTemplate let-json1 let-json2="b">
<div>{{json1}}</div></div>{{json2}}</div>
</ng-template>
或2:
or 2:
context: {$implicit: {a: jsonObj1, b:jsonObj2}}
使用
<ng-template #filterTemplate let-json1>
<div>{{json1.a}}</div></div>{{json1.b}}</div>
</ng-template>
或3:
or 3:
context: {a:jsonObj1, b:jsonObj2}
使用
<ng-template #filterTemplate let-json1="a" let-json2="b">
<div>{{json1}}</div></div>{{json2}}</div>
</ng-template>
这篇关于使用$ implict传递多个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文