Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

primeng - How to dynamically change the header of the p-dialog of PRIMNG in angular

I am using primeng Dialog box and wanted to change the header of the dialog dynamically.

for example - if the user opens to Add user show the title as Add user if open to edit change the title to Edit user.

I have tried using interpolation as header = {{ formTitle }} but it not taking. As formTitle is a input variable that holds a value. I want to set this variable in the header.

This is the tag where we have a header tag to have dynamic text -

<p-dialog header="Header" [(visible)]="displayBasic" [style]="{width: '50vw'}" [baseZIndex]="10000">

What method should I use to change the header of p-dialog dynamically?

question from:https://stackoverflow.com/questions/65882964/how-to-dynamically-change-the-header-of-the-p-dialog-of-primng-in-angular

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use a nested build-in element of P-dialog i.e.

<p-dialog>
   <p-header> {{ formTitle }} </p-header>

   Body content ...
   <p-footer> Content ... </p-footer>
</p-dialog>

Added body and footer just for completeness purposes.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...