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
In a recent update, a change was made to the way the $modelValue is populated based on the validity of the field. If the field is invalid, the $modelValue will be set to undefined and a new attribute, $$invalidModelValue will be populated with the value.
As a solution to work with 1.2.* and 1.3.* I have come up with this:
.directive('match', function () {
return {
require: 'ngModel',
restrict: 'A',
scope: {
match: '='
},
link: function(scope, elem, attrs, ctrl) {
scope.$watch(function() {
modelValue = ctrl.$modelValue || ctrl.$$invalidModelValue;
return (ctrl.$pristine && angular.isUndefined(modelValue)) || scope.match === modelValue;
}, function(currentValue) {
ctrl.$setValidity('match', currentValue);
});
}
};
});
Plunkr
While this solution works with both version, 1.3.* has the new $validators pipeline which is recommended for the new version.