title: Setting view value an input field in a unit test of an angular form directive
body: <p>I have a directive that builds a form:</p>
  
  <pre><code>app.directive('config', function() {
    return {
      restrict: 'E',
      scope: {
        data: '='
      },
      template: '&lt;form name="configForm"&gt;' +
        '&lt;input type="number" max="10" ng-model="config.item" name="configItem"/&gt;' +
        '&lt;div class="form-error" ng-show="configForm.$error.max"&gt;Error&lt;/div&gt;' + 
        '&lt;/form&gt;',
      controller: 'ConfigDirectiveController',
    };
  });
  </code></pre>
  
  <p>What I want to do is validate via a unit test that the error message will show up given some input. With angular 1.2 I could modify $scope.config.item and it would update the view value and show the error.</p>
  
  <p>As near as I can tell, with angular 1.3, if the model does not pass validation the view value does not get updated...so I need to modify the view value to make sure the error message shows up.</p>
  
  <p>How can I get access to the "configItem" input so that I can set the view value to ensure that the error message will show up?</p>
  
  <p><strong>Edited to show unit test</strong></p>
  
  <p>I see that the value is set properly, but the error still has an ng-hide applied to the tag. When I am viewing the page and manually changing the input value, the ng-hide will be removed and the error will display if I enter in something greater than 10.</p>
  
  <pre><code>  beforeEach(inject(function($compile, $rootScope) {
        element = angular.element('&lt;config data="myData"&gt;&lt;/config&gt;');
        $scope = $rootScope.$new();
        $scope.myData = {};
        element = $compile(element)($scope);
      }));
  
      it('should warn that we have a large number', function() {
        var input = element.find('[name="configItem"]')[0];
        $scope.$apply(function() {
          angular.element(input).val('9000000001');
        });
        errors = element.find('[class="form-error ng-binding"]');
        expect(errors.length).toBe(1);
      })
  </code></pre>