app.directive('noDirtyCheck', [function () { // Interacting with input elements having this directive won't cause the // form to be marked dirty. // http://stackoverflow.com/questions/17089090/prevent-input-from-setting-form-dirty-angularjs return { restrict: 'A', require: 'ngModel', link: function (scope, element, attrs, ctrl) { element[0].focus(function () { ctrl.$setPristine(); }); //element[0].onblur(function () { // ctrl.$setPristine(); //}); } }; }]);and the control defined as
<input class="form-control ng-valid ng-dirty ng-valid-parse ng-touched" type="text" ng-model="searchTerm" name="searchTerm" id="searchTerm" data-no:dirty-check="" placeholder="Search">(this is what I see when I inspect the element).
<div class="col-lg-5 col-lg-offset-1"> <input class="form-control" type="text" ng-model="searchTerm" name="searchTerm" id="searchTerm" data-no:dirty-check placeholder="@Labels.search" /> </div>The directive seems to work fine in another form and it's not working in this form. These things are driving me crazy :(