0

In the following code snippet, status is returning 0 or 1, but I would like to evaluate and display the word "New" whenever status is returning 0 and "Old" whenever log.status is returning 1. How could I evaluate and change the value on client side?

     <table class="table table-striped table-hover table-bordered table-condensed">
        <thead>
            <tr>
                <th>Date</th>
                <th>Status</th> 
        </thead>
        <tr class="info" ng-repeat="log in vm.data>
            <td>{{log.Date | date}}</td>
            <td>{{log.Status}}</td>
        </tr>
     </table>
0

1 Answer 1

2

The out of the box solution is

{{ log.Status == 0 ? 'New' : 'Old'}}

Another way to do it is to create a small filter.

.filter('condition', function () {
    return function(input, trueValue, falseValue) {
        return input ? trueValue : falseValue;
    };
})

And then in your code

{{ log.Status | condition: 'Old' : 'New' }}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.