title: compare two input field values in a table using angular
body: <p>I am a beginner in angularjs and I am trying to make a dynamic table but with custom validations. for instance, I have 2 input fields namely totalSalary and pension paid. The pension paid entered should not be greater than the totalSalary. I am trying to build a custom directive for the pension paid field but how to get the value of the totalSalary field to do the comparison?
  Thanks to help.
  Ashley
  Updated:</p>
  
  <p>This is the table I have made so far as per the next link. <a href="http://i.stack.imgur.com/oV0rw.jpg" rel="nofollow">Dynamic table made so far</a>
  Below are two fields I need to compare.</p>
  
  <pre><code> &lt;td&gt;&lt;input type="text" class="form-control" ng-model="employee.details.salary" fcsa-number required/&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" class="form-control" ng-model="employee.details.pension" fcsa-number not-greater-than-yearly-sal required/&gt;&lt;/td&gt;
  </code></pre>
  
  <p>The directive so far I have worked on is as per below. I got the value of pension1 but now how to get the value of salary. On leaving the input for pension1, if the amount is greater than the salary, it should prompt the user and clear the value.</p>
  
  <pre><code>angular.module('app').directive("notGreaterThanYearlySal", function () {
    return {
      restrict: "A",
      require: "?ngModel",
      link: function (scope, element, attributes, ngModel) {
        element.bind('blur', function(event){
          alert(element.val());
        });
      }
    };
  });
  </code></pre>