>><div class="col-lg-12"> >> <div class="form-group row col-lg-12"> >> >> <div class="checkbox pull-left"> >> <input type="checkbox" name="showFinalized" id="showFinalized" >> ng-model="showFinalized" >> ng-change="search()" >> data-no:dirty-check />@String.Format(Labels.showFinalizedX, Labels.invoices).TrimEnd() >> </div> >> </div> >> </div>>>
(function () { 'use strict'; var app = angular.module('sysMgrApp'); 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.focus(function () { ctrl.$pristine = false; }); } }; }]); })();BTW, I was wrong saying that ng-change is not firing. I had a breakpoint on the wrong line. It does fire but in the code the $scope.showFinalized is always false regardless on what state the checkbox is.