Ternary operator for values in Angular 2+ template
- It seems that you are trying to display unit of selected sport.
- It is better to keep the logic in controller and populate it in model object and view just display the model.
- Diluting the logic in view layer may not a better design and violates law of single responsibility.
You can use Conditional (ternary) operator, inside of template like below example
<span> {{selectedSport.key === 'walking' ? 'steps' : 'km'}} </span>