'Angular 7: Ternary operator on binding

I am using angular 7. Below is what I am trying in history-dialog.component.html where it should display updated-by-contact ( if exists) or it should display created-by-contact in "updatedBy" column on the screen.

<wj-flex-grid-column [binding]="'updatedBy'? 'updatedBy' : 'createdBy'" [align]="'center'" [header]="'Updated By'" [isReadOnly]="'true'" [width]="200">

However, What I am seeing is :

If updatedBy = null and createdBy = "[email protected]" , result on the screen is empty. Although when data.updatedBy has something, it is displaying right. Any idea what's going wrong here?



Solution 1:[1]

You are passing updatedBy and createdBy as string here. Use in this way.

<wj-flex-grid-column [binding]="updatedBy ? updatedBy : createdBy" [align]="'center'" [header]="'Updated By'" [isReadOnly]="'true'" [width]="200">

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Justwell Solets