简体   繁体   English

如何在组件 ContextMenu 的 primeNG 中使用属性 appendTo?

[英]How to use attribute appendTo in primeNG in component ContextMenu?

我正在尝试在组件ContextMenu中使用属性appendTo ,但我想将行为附加到一个元素,例如 div。

on the element u want to append to add a hashtag #myHashTag and on the prime element u want to append add: [appendTo]="myHashTag" <- without the # sign在您要附加的元素上添加主题标签#myHashTag,在您要附加的主要元素上添加:[appendTo]="myHashTag" <- 不带 # 符号

example:例子:

<div class="recording-control-button" #stopbutton></div>

<p-confirmDialog [appendTo]="stopbutton"></p-confirmDialog>

I'm presuming you're using Angular 2?我假设您使用的是 Angular 2?

Based on the information on the api for primeng context menu here:根据这里有关primeng上下文菜单的api的信息:

PrimeNg context menu PrimeNg 上下文菜单

You need to use a Angular 2 template variable, see here:您需要使用 Angular 2 模板变量,请参见此处:

Angular 2 HTML variables Angular 2 HTML 变量

I try this and it works - [appendTo]="'body or template or any Id'"我试试这个,它有效 - [appendTo]="'body or template or any Id'"

For example: <div #largeModal></div> - define anywhere in html, but in your project例如: <div #largeModal></div> - 在 html 中的任何位置定义,但在您的项目中

Define this menu primeng in your html <ng-template let-item="rowData" <p-menu #menu popup="popup" [model]="items"></p-menu> <button type="button" pButton icon="fa fa-list" label="Show" [appendTo]="'largeModal'" (click)="menu.toggle($event)"></button> </ng-template>在你的 html <ng-template let-item="rowData" <p-menu #menu popup="popup" [model]="items"></p-menu> <button type="button" pButton icon="fa fa-list" label="Show" [appendTo]="'largeModal'" (click)="menu.toggle($event)"></button> </ng-template>中定义这个菜单primeng <ng-template let-item="rowData" <p-menu #menu popup="popup" [model]="items"></p-menu> <button type="button" pButton icon="fa fa-list" label="Show" [appendTo]="'largeModal'" (click)="menu.toggle($event)"></button> </ng-template>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM