I\'m having some basic trouble with a form. Here\'s what I did.
I snagged this cool looking directive from here: https://github.com/TheSharpieOne/angular-input-matc
It looks like maybe using $setValidity is not the way to go here. I found this question that proposes a different solution, using $validators and $validate(), and this is working for me great. The new code looks like this:
directive('match', function () {
return {
require: 'ngModel',
restrict: 'A',
scope: {
match: '='
},
link: function(scope, elem, attrs, ngModel) {
scope.$watch('match', function(pass){
ngModel.$validate();
});
ngModel.$validators.match = function(modelValue, viewValue){
var value = modelValue || viewValue;
var match = scope.match;
return value === match;
};
}
};
});