title: How should I access an element's angularjs $ngModelController in a jasmine unit test?
body: <p>I'm currently using <code>directiveElement.data("$ngModelController")</code> to get access to the element's <code>$ngModelController</code>, as in the following example.</p>
  
  <pre><code>describe("directiveElement", function () {
    it("should do something with ngModelController", inject(function($compile, $rootScope) {
      var directiveElement = $compile("&lt;input ng-model="myNgModel" customDirective type="text"&gt;&lt;/input&gt;")($rootScope);
      $rootScope.$digest();
      var ngModelCtrl = directiveElement.data("$ngModelController");
      ngModelCtrl.$modelValue = "12345";
      // do rest of test
    }));
  });
  </code></pre>
  
  <p>However, I want to know if there is a better to access the <code>$ngModelController</code>, or if accessing the <code>$ngModelController</code> is a bad idea?</p>