0

I want to applay css class on that row where MaxStockLevel Is greter than Balence i had try this code

<tbody ng-repeat="i in products | filter:productFilter">
  <!--<tr ng-class="{{i.MaxStockLevel > i.Balence ? 'danger' : 'danger'}} ">-->
  <tr class="ng-class : i.maxstocklevel > i.Balence">
    <td>{{i.Name}}</td>
    <td>{{i.MinStockLevel}}</td>
    <td>{{i.MaxStockLevel}}</td>
    <td>{{i.Balence}}</td>
  </tr>
</tbody>

3 Answers 3

1

Your syntax is a bit off:

<tr ng-class="{ 'myCustomClass' : i.maxstocklevel > i.Balence }">

(Also, "Balence" is spelled "Balance")

Sign up to request clarification or add additional context in comments.

1 Comment

Note, quotes are not necessary here, as it's just a JS map. You may find quotes helpful if you have dashes or other symbols in your class name.
1

you should try the following line

<tr ng-class="{ 'YourClassName' : i.maxstocklevel > i.Balance }">

For more info about ng-class click here

Comments

0

ng-class takes a JavaScript object which maps class names to booleans, like so:

var app = angular.module('app', []);

app.controller('Main', function($scope) {
  $scope.maxStockLevel = 50;
  
  $scope.items = [];
  for (var i = 0; i < 10; ++i)
  {
    $scope.items.push({ stockLevel: Math.random() * 100 });
  }
});
.danger { background: red; }
<div ng-app="app" ng-controller="Main">
  <div ng-repeat="i in items" ng-class="{ danger: i.stockLevel > maxStockLevel }">
    Item {{ $index }}
  </div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.js"></script>

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.