2

I have table: order id,status

status value: (closed,canceled)
Value get from maria-db.

This result I want see in html page(table).

  • closed: color -- red
  • canceled: color -- green

This my td:

<td>{{data.orderid}}</td>
<td>{{data.status}}</td>

I use angularjs, (php for connection).

I tried this:

$('.status:contains("closed")').css('color', 'red'); 
$('.status:contains("canceled")').css('color', 'green');
8
  • 1
    Cool. How have you tried to accomplish your goal? (We're not here to write code for you; we're here to help you with your code. Please take the tour and read How to Ask.) Commented Mar 31, 2018 at 15:22
  • Sorry,I try this code but is not working for me: Commented Mar 31, 2018 at 15:27
  • $('.status:contains("closed")').css('color', 'red'); $('.status:contains("canceled")').css('color', 'green'); Commented Mar 31, 2018 at 15:28
  • Please show your relevant HTML also. And are you asking about jQuery or Angular? Which libraries are loaded? Commented Mar 31, 2018 at 15:33
  • I think better with Angular Commented Mar 31, 2018 at 15:39

1 Answer 1

3

you can you angular expression for this

  1. Make two style with name greenStyle and redStyle

    .greenStyle{ color:green; }

    .redStyle{ color:red; }

  2. In your table add.

<td>{{data.orderid}}</td>
<td class="{{data.status=='closed'?'redStyle':'greenStyle'}}">{{data.status}}</td>

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.