如何动态传递组件实例?

时间:2019-05-03 09:36:11

标签: angular

我是Angular的新手,所以您可以为我解决以下问题: 我正在使用一个popover库,我需要动态传递一个实例以打开popover。 我将名称设置为[mdePopoverTriggerFor],然后需要将字符串值(indicator.value)传递给mde-popover(component)作为实例名称(#indicator.value)

<div *ngFor="let indicator of sortByScore(mergedIndicators)" class="indicator indicator-text">
                            {{translations.static[indicator.indicatorCode]}}
                                <!--*** TRIGGER FOR OPENING **-->
                                <i 
                                    *ngIf="indicator.tags.length>0" 
                                    class="fas fa-comment-alt"
                                    <!--** here I assign the name for instance -->
                                    [mdePopoverTriggerFor]="indicator.value"
                                    mdePopoverTriggerOn="click"></i>


                                <!--** POPOVER  -->
                                <mde-popover #indicator.value="mdePopover" [mdePopoverOverlapTrigger]="false">
                                    <mat-card style="max-width: 300px">

                                        <mat-card-title>Tip</mat-card-title>
                                        <mat-card-content>
                                            Numerical representation of the threat level in meta-percentage value (could exceed 100%), if more than the danger threshold (85% by default) - is considered malicious (highlighted in red). The threshold is set by the tLab administrator.
                                        </mat-card-content>
                                    </mat-card>
                                </mde-popover>

                            </div>

0 个答案:

没有答案