On my controller, I have something like:
this.user = {
first_name: "David",
full_name: "David Silva"
}
The data I receive sometimes does not have a full_name, so I tried this expression:
{{user.full_name || user.first_name}}
It seems to work, but after a more thorough study, I understand that it does not behave the way it will in normal JS. I expected that if full_name was undefined or empty, it will try to use another, but instead, if the expression after ||is valid, it will be evaluated this way, regardless of the expression on the left.
I could not understand why, and I would like to know more about how this is interpreted in order to use it correctly.
source
share