javascript - Select the color of row based on end point JSON value using AngularJS -
i have program written in angularjs, lists values coming end point in rows. want give color of rows based on json value. angularjs plnkr link :-
http://plnkr.co/edit/x8l5wwbivwnzjolxohtg?p=preview
json structure :-
{ "1": { "venture": "xyz informatics", "member": [ { "name": "abcd", "email": "abcd@gmail.com" } ], "message": "this day", "isclicked": true }, "2": { "venture": "bbc informatics", "member": [ { "name": "xyz", "email": "xyz@gmail.com" } ], "message": "this bad day", "isclicked": false } }
output show :-
xyz informatics bbc informatics
i want give green color of row if "isclicked": true
, red color when "isclicked": false
as example xyz informatics
row color should green , bbc informatics
in red.
add function following retrieving color:
$scope.getcolor = function(el) { if (!el.isclicked) { return {'color': 'red'}; } else { return {'color': 'green'}; } };
in way it's possible assign color on html in way:
<tr ng-repeat="data in datas"> <td ng-style="getcolor(data)">{{ data.venture }}</td> </tr>
updated example: http://plnkr.co/edit/y2rsf1h372vyqzzg4fpn?p=preview
Comments
Post a Comment