Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Placeholder does not appear, when [value]-attribute is undefined using pInputTextarea

I have a readonly-textarea that should display values of a certain object.

If the object is undefined, it will show "undefined" inside the textarea as well instead of the placeholder. I specifically want to use a placeholder instead of returning the values inside my function when the object is undefined. How can i achieve this?

https://stackblitz.com/edit/primeng-inputtextarea-demo-vbm6zp?file=src%2Fapp%2Fapp.component.html

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Returns an empty string or null instead of undefined will show the placeholder value.

showSomething(person: Person): string {
  if(!person) {
    return null;
  }
  return person.name + ' ' + person.surname;
}

Demo @ StackBlitz

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading