title: Is it possible to use NgModelController validation on a directive without any input elements?
body: <p>I built a toggle switch using css where clicking on the control simply adds and removes a CSS class which causes the toggle switch to animate.  I want to get this toggle switch in a form with validation and specifically want to set the control to $dirty = true whenever they click on the control.</p>
  
  <p>I set up my directive by setting <code>require: 'ngModel'</code> and then settings the controller in the link function to dirty like this:</p>
  
  <pre><code>link: function(scope, elem, attrs, ctrl){
              var hasCallback = angular.isDefined(attrs.callback);
  
              scope.toggle = function(e){
  
                  if(hasCallback){
                      scope.skcallback({event:e});
                  }else{
                      scope.ngModel = !scope.ngModel;
                  }
  
                  //ctrl.$setDirty(); // This didn't work and didn't even appear to be on the ctrl object
                  ctrl.$dirty = true;
                  ctrl.$pristine = false;
  
              }
  
             scope.$watch('disabled', function(value){
                 if(value){
                     elem.addClass('disabled');
                 }else{
                     elem.removeClass('disabled');
                 }
             })
         }
  </code></pre>
  
  <p>I tried a number of different things to get the validation to work but when I inspect the DOM the control is always set to ng-pristine and doesn't appear to ever get set to dirty.  What am I doing wrong?</p>