title: AngularJS - Input change outside directive value passed in to directive
body: <p>I am a beginner to AngularJs and I cannot figure out how to retrieve data from outside a directive. I have various input being updated and I need the directive to take this data and work with it.</p>
  
  <p>For example, in the code below, the first input field is hooked up to the directive and works fine, but without putting the directive attribute on the second input field, how can the data typed in that field be updated in the directive?</p>
  
  <p>HTML:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div ng-app="myDirective"&gt;
      &lt;input type="text" ng-model="test1" my-directive&gt;
      &lt;input type="text" ng-model="test2"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Directive:</p>
  
  <pre class="lang-js prettyprint-override"><code>angular.module('myDirective', [])
      .directive('myDirective', function () {
      return {
          restrict: 'A',
          link: function (scope, element, attrs) {
              scope.$watch(attrs.ngModel, function (v) {
                  console.log('New Value from field 1: ' + v);
                  //console.log('New Value from field 2: ' + ???);
              });
          }
      };
  });
  </code></pre>