title: How to get previous value and compare with new value before bind value in angularjs
body: <p>I'm working with real time application to show current gold market rates. I'm getting service by ajax and convert the value and displaying into tables. Currently create dynamically this table and append into div. So i can compare with table row data with currently getting value and can set price up/ down or normal color value like bellow,</p>
  
  <pre><code>var tableid = document.getElementById("ratetable");
  for(var i=1;i&lt;tableid.rows.length;i++) {
      selling_rate = data.Commodities.Commodity.selling_rate;
      buying_rate =  data.Commodities.Commodity.buying_rate;
  
      if(tableid.rows[i].cells[1].innerHTML &gt; selling_rate) {
          tableid.rows[i].cells[1].style.color = "#FFFFFF"; //Red
          tableid.rows[i].cells[1].style.background = "#FF0000";
      } else if(tableid.rows[i].cells[1].innerHTML &lt; selling_rate) {
          tableid.rows[i].cells[1].style.color = "#ffffff"; //Green
          tableid.rows[i].cells[1].style.background = "#2636f2";
      } else {
          tableid.rows[i].cells[1].style.color = "#000000"; //black
          tableid.rows[i].cells[1].style.background = "";
      }   
      tableid.rows[i].cells[1].innerHTML = selling_rate;
  
  }
  </code></pre>
  
  <p>For this i used bellow code to create table in angular js</p>
  
  <pre><code>&lt;table width="480" border="0" cellpadding="0" cellspacing="0" class="rate-table" id="ratetable"&gt;
                                      &lt;tr class="table-title"&gt;
                                          &lt;td width="297"&gt;DESCRIPTION&lt;/td&gt;
                                          &lt;td width="183"&gt;PRICE&lt;/td&gt;
                                      &lt;/tr&gt;
                                        &lt;tr ng-repeat="commodity in commodityrate.Commodity" ng-class-odd="'oddrow'" ng-class-even="'silver'"&gt;
                                            &lt;td width='297'&gt;{{commodity.name}}&lt;/td&gt;
                                            &lt;td width='183'&gt;{{commodity.selling_rate}}&lt;/td&gt;
                                      &lt;/tr&gt; 
  
                              &lt;/table&gt;
  </code></pre>
  
  <p>But I need to check value (compare new value with previous value) and update color code. for this i tried like</p>
  
  <pre><code>ng-class="{highcolor: $scope.text&gt;commodity.selling_rate, lowcolor: $scope.text&lt;commodity.selling_rate, normalcolor: $scope.text==commodity.selling_rate}"
  </code></pre>
  
  <p>But this didn't work, how to do this in angular js. Is there any way to do this dynamic created value to compare by angular $watch.  Please any one help me.</p>