问题
I would like to give a default value of a variable in my view if it's empty or not defined :
<p>{{(person | async)?.name}}</p>
If the field name
is empty, i would like to see this :
<p>Default value</p>
How can i do this ?
回答1:
use ||
operator
<p>{{(person | async)?.name || 'Default value'}}</p>
来源:https://stackoverflow.com/questions/51139331/angular-2-default-value-in-view