Нема описа

passwordMatch.js 479B

12345678910111213141516171819
  1. angular.module('MyApp')
  2. .directive('passwordMatch', function() {
  3. return {
  4. require: 'ngModel',
  5. scope: {
  6. otherModelValue: '=passwordMatch'
  7. },
  8. link: function(scope, element, attributes, ngModel) {
  9. ngModel.$validators.compareTo = function(modelValue) {
  10. return modelValue === scope.otherModelValue;
  11. };
  12. scope.$watch('otherModelValue', function() {
  13. ngModel.$validate();
  14. });
  15. }
  16. };
  17. });