I have a call in AngularJS to $http Get which is returning data. I have a boolean field PassFail that currently appears as "true" or "false". I want it to display "Pass" or "Fail". I've tried adding a PassFail function in $scope and $rootScope but nothing works for me. I think there is some easy solution but it will probably take me days to figure this out on my own. Can you help?
var oApp = angular.module("myApp", []);
oApp.controller("certificationsCtrl", function ($scope, $http)
{
$scope.Exams = {};
$scope.GetPassFail = function (passFail)
{
return passFail ? "Pass" : "Fail";
};
$scope.ShowExams = function (certificationID)
{
var url = "http://localhost:49861/api/Exams?id=" + certificationID + "&extra=0";
$http({
method: "GET",
url: url
}).then(function mySuccess(response)
{
$scope.Exams = response.data;
}, function myError(response)
{
alert("error response.statusText = " + response.statusText);
});
}
});
<tr ng-repeat="x in Exams">
<td style="border: 1px solid black;">{{ x.ExamNumber}}</td>
<td style="border: 1px solid black;">{{ x.ExamShortName }}</td>
<td style="border: 1px solid black;">{{ x.PassFail | GetPassFail }}</td>
MM-dd" }}</td>
</tr>