I’m so happy to have you again!
In this brief blog, I am going to help you understand conditional formatting and how to apply it using css.
What is Conditional Formatting?
Conditional Formatting also called Conditional Styling is a situation where styles are apply to html element based on conditions that may changes at view time. For example, based on values from data in a database.
When to use Conditional Formatting
A typical example of when you can use conditional formatting is when the color of the text needs to change depending on the status. For example:
- Status: Pending
- Status: In Progress
- Status: Completed
How to Apply it In angularjs, you can achieve conditional formating using either
- ng-class
- ng-style
Using ng-class Cleate two classes called Pending and Completed
css Style
.pending { color: red; } .completed { color: green; }
Then in your table use the html markup below:
<table ng-repeat = "row in activities" width="364" height="140" border="1"> <tr> <td>Create C# Tutorial </td> <td ng-class="{'pending':row.status === 'Pending'}, 'completed':row.status ==="Completed>{{row.status}}</td> </tr> <tr> <td>Do a Presentation on .Net</td> <td ng-class="{'pending':row.status === 'Pending'}, 'completed':row.status ==="Completed>{{row.status}}</td> </tr> </table>
The output is as shown below:
Let’s now see how to do it using ng-style
I have been exploring for a little for any high quality articles or blog posts on this kind of house .
Exploring in Yahoo I eventually stumbled upon this site.
Reading this information So i am glad to exhibit that I’ve an incredibly excellent uncanny feeling I discovered
exactly what I needed. I such a lot without
a doubt will make certain to do not disregard this web site and give it
a look regularly.
I don’t know anything about coding, but where the end brace is and where the close ” is look wrong…
{{row.status}}