I'm getting Bool value from database to angularJs
<td>
{{patient.Alcoholic}}
</td>
instead of false or ture i need to print YES or NO
<td>
{{patient.Alcoholic // can i have if-else condition over here ??}}
</td>
<td>
{{true == patient.Alcoholic ? 'Yes' : 'No' }}
</td>
This should work!
{{patient.Alcoholic ? 'Yes' : 'No' }}use ng-if directive
<td ng-if="patient.Alcoholic">Yes</td>
<td ng-if="!patient.Alcoholic">NO</td>
Try to not put JS operations in your template, as it will:
$digest cycle.If you are fine with modifying the original bool of the patient:
$scope.patient.Alcoholic = !!$scope.patient.Alcoholic ? 'Yes' : 'No';
If not, I would add another property onto patient:
$scope.patient.isAlcoholic = !!$scope.patient.Alcoholic ? 'Yes' : 'No';
And then in your view (dependent on the solution you've chosen of the two above):
{{ patient.Alcoholic }}
<!-- or -->
{{ patient.isAlcoholic }}
That's my two cents on keeping your template clean.