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

89 Views Asked by At

I have a read-only textarea that should display the 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

1

There are 1 best solutions below

2
Yong Shun On BEST ANSWER

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