Home > Mobile >  Td with "undefined" values
Td with "undefined" values

Time:05-13

I want to replace my "undefined" values in my table with " ", to get only empty cells.

This is what i tried:

    <tr *ngFor="let name of data">
            <td>
                {{name !== undefined ? name : ''}}
            </td>

Nothing changed, how can i manage the undefined values?

CodePudding user response:

Try like this.

If name contains any real value it will be used, otherwise empty string

 {{name || ''}}

If name contains "undefined" world as string, rule above will print that string

CodePudding user response:

You can do this:

{{ name ? name : ''}}

so whenever name is falsy, and undefined is falsy, it will return an empty string, when it's truthy it will return name.

  • Related