Reputation: 516
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>
Upvotes: 8
Views: 12153
Reputation:
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.
Upvotes: 1
Reputation: 786
<td>
{{true == patient.Alcoholic ? 'Yes' : 'No' }}
</td>
This should work!
Upvotes: 19
Reputation: 15393
use ng-if directive
<td ng-if="patient.Alcoholic">Yes</td>
<td ng-if="!patient.Alcoholic">NO</td>
Upvotes: 11