我有一个想要附加到父div的PrimeNG组件,但它似乎总是附加到正文中.
import { Component } from '@angular/core';
import { ConfirmationService, MessageService } from 'primeng/api';
import { ConfirmPopupModule } from 'primeng/confirmpopup';
@Component({
selector: 'app-prime-button',
standalone: true,
imports: [ConfirmPopupModule],
providers: [ConfirmationService, MessageService],
template: `<div #appendMe>appendme</div>
<p-confirmPopup [appendTo]="appendMe"></p-confirmPopup>
<button (click)="confirmationService.confirm({ message: 'test' })">
open confirm
</button> `,
styleUrl: './prime-button.component.css',
})
export class PrimeButtonComponent {
constructor(
public confirmationService: ConfirmationService,
public messageService: MessageService
) {}
}
我知道可以使用属性[appendTo],使用模板变量,并将相应的元素作为接收附加元素的目标.
使用方括号将appendTo括起来,我得到以下错误:
Can't bind to 'appendTo' since it isn't a known property of 'p-confirmPopup'.
个
AppendTo前后没有方括号,元素仍会附加到HTML体中.
如您所见,我已经在修饰器和导入中将Confix PopupModule导入到独立组件中.属性appendTo似乎不存在于在PrimeNG NODE_MODULES文件夹中找到的confirmpopup.d.ts文件中定义的类Confix Popup上.
如何将此弹出元素附加到父div?
谢谢你的阅读.