Issue
I am adding an angular condition for my MatToolTip. At first this following works for just 1 string assignment
matToolTip={{myData.name}}
But I need to add a condition like the following
matToolTip={{ myData.hasName : myData.name, myData.hasNoName : myData.NoNameMessage }}
The data coming in has one or the other, never both.
I found another stackoverflow which ppl says the following works but not in my Angular 7 code
{{element.source == 1 ? 'upwork' : (element.source == 2 ? 'refer from friend' : '')}}
I tried putting them in single quote but no success. any help is greatly appreciated. Thanks.
Solution
Try this:
[matTooltip]="myData.hasName ? myData.name : (myData.hasNoName? 'myData.NoNameMessage' : null)"
Answered By - Nadhir Falta
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.