Is a filter a good way to accomplish a dynamic class in angular? I want to apply a different badge color with bootstrap depending on a number.

I wrote a filter to accomplish this...

angular.module('Demo')
    .filter('reserveStatus', function() {
        return function(num) {
            var klass = "";

            num = parseInt(num, 10);

            if (num &gt; 2 &amp;&amp; num &lt; 5) {
                klass = "alert-success";
            }                    
            else if (num &gt;= 5 &amp;&amp; num &lt; 10) {
                klass = "alert-warning";
            }
            else if (num &gt;= 10) {
                klass = "alert-danger";
            }

            return klass;
        }
    });


And it's used with interpolation like this...

&lt;span class="badget {{reserve.qty | reserveStatus}}"&gt;&lt;/span&gt;


Is this a good way to accomplish this?
Fun question, I think this is okay.

I would name klass -> class and I would consider building a map for the values:

var classMap = [
  { from : 3 , to : 5       , class : 'alert-success' },
  { from : 5 , to : 10      , class : 'alert-warning' },
  { from : 10, to : Infinity, class : 'alert-danger'  }
];