如何在click()函数中使ng2-right-click-menu传递数据?

时间:2019-07-30 20:22:15

标签: angular

我正在使用ng2-right-click-menu和Angular8。我有如下菜单和上下文菜单设置:

                        <label for="field_specialConditions">Special Conditions</label>
                    <select class="form-control" id="field_specialConditions" multiple name="specialConditions"
                        formControlName="specialConditions">
                            <option
                            [shAttachMenu]="specialConditionsMenu" [shMenuData]="specialConditionsOption"    
                            [ngValue]="getSelected(editForm.get('specialConditions').value, specialConditionsOption)"
                                *ngFor="let specialConditionsOption of specialconditions; trackBy: trackSpecialConditionsById"
                                >
                                {{specialConditionsOption.conditionDescription}}

                            </option>
                    </select>

我还具有如下上下文菜单设置:

<sh-context-menu #specialConditionsMenu >
<ng-template shContextMenuItem let-data (click)="newSpecialCondition()">
    <div>
        <fa-icon [icon]="'plus'"></fa-icon> New Special Condition
    </div>
</ng-template>
<ng-template shContextMenuItem let-data (click)="editSpecialCondition(data.id)">
    <div>
        <fa-icon [icon]="'edit'"></fa-icon> Edit {{data?.conditionDescription}}
    </div>
</ng-template>
<ng-template shContextMenuItem let-data (click)="viewSpecialCondition()">
    <div>
        <fa-icon [icon]="'binoculars'"></fa-icon> View {{data?.conditionDescription}}
    </div>
</ng-template>

问题是数据没有在随后定义的中定义。如何从specialConditionsOption中捕获选定的ID,并将其绑定到editSpecialCondition()函数?

0 个答案:

没有答案