I´m trying to use the attribute appendTo
in the component ContextMenu, but I want attach the behavior to one element, like a div.
Asked
Active
Viewed 2.7k times
13

Deilan
- 4,740
- 3
- 39
- 52

Jhonatan Delgado
- 131
- 1
- 1
- 4
-
Solved https://github.com/primefaces/primeng/issues/479 – Jhonatan Delgado Dec 16 '16 at 17:17
3 Answers
15
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
example:
<div class="recording-control-button" #stopbutton></div>
<p-confirmDialog [appendTo]="stopbutton"></p-confirmDialog>

asafrob
- 1,838
- 13
- 16
-
3I'm doing the same with a sidebar component, but no matter what element I attach it to, it still takes up the whole space/height on the left of the screen :-( – AsGoodAsItGets Oct 05 '18 at 10:19
-
0
I'm presuming you're using Angular 2?
Based on the information on the api for primeng context menu here:
You need to use a Angular 2 template variable, see here:

Mark
- 44
- 4
-
1can you elaborate on the template variable im not quite sure on how to use it – naoru Jan 20 '17 at 05:53
0
I try this and it works - [appendTo]="'body or template or any Id'"
For example:
<div #largeModal></div>
- define anywhere in html, but in your project
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>

Amitesh Singh
- 162
- 2
- 7