We have a mover directive that uses 2 list controls. The problem is that when I simply click on an item in the assigned items list, it makes my form dirty. I tried the following solution in the directive controller onChanged event (which is called by the second list ng-change):
$scope.onChanged = function (assigned) {
var currentState = $scope.form.$dirty;
$scope.selectedItem = assigned[0];
if (currentState === false)
$scope.form.$setPristine();
}
However, the currentState is already true, so my code does nothing. How can I prevent the clicking in the list control to set form's dirty status? I found two related questions How can I exclude controls from making form Dirty? and How can I denote which input fields have changed in AngularJS but it's not clear to me if I should try either of these solutions. The code checks for $scope.form.$dirty in a few places, so the best solution is somehow to make sure that clicking on the list doesn't make it dirty. I also have noDirty directive which I haven't yet tried applying to that list. I'm going to try that now.