On my controller I have something like:
this.user = {
first_name: "David",
full_name: "David Silva"
}
The data I get sometimes doesn't have full_name, so I tried this expression:
{{user.full_name || user.first_name}}
It seems to be working but after closer inspection I realize that it doesn't behave how it would in regular JS. I was expecting that if full_name was undefined or empty it would try the other one, but instead if the expression after the ||
is valid it will evaluate to that regardless of the expression on the left.
I couldn't find out why, and I would like to know more about the way this is interpreted to take proper advantage of it.
this
on the controller? If so, then the controller is being used as a viewmodel so you would access the data somewhat differently than if you were using scope.