Skip to content

Commit

Permalink
Merge pull request #26 from eyeview-opensource/master
Browse files Browse the repository at this point in the history
Support ng-repeat and ng-if.
  • Loading branch information
Jakobovski committed Mar 8, 2015
2 parents e0ffaa5 + 69e7ed7 commit 3690ac0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions dist/angular-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ angular.module('angularValidator').directive('angularValidator',
}
});

// Watch form length to add watches into new form elements
scope.$watch(function(){return DOMForm.length;}, function(){
setupWatches(DOMForm);
});

// Setup watches on all form fields
setupWatches(DOMForm);

Expand All @@ -51,6 +56,12 @@ angular.module('angularValidator').directive('angularValidator',
// Setup $watch on a single formfield
function setupWatch(elementToWatch) {

//Prevent to re-watch the element
if (elementToWatch.isWatchedByValidator){
return;
}
elementToWatch.isWatchedByValidator = true;

// If element is set to validate on blur then update the element on blur
if ("validate-on" in elementToWatch.attributes && elementToWatch.attributes["validate-on"].value === "blur") {
angular.element(elementToWatch).on('blur', function() {
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-validator.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/angular-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ angular.module('angularValidator').directive('angularValidator',
}
});

// Watch form length to add watches into new form elements
scope.$watch(function(){return DOMForm.length;}, function(){
setupWatches(DOMForm);
});

// Setup watches on all form fields
setupWatches(DOMForm);

Expand All @@ -51,6 +56,12 @@ angular.module('angularValidator').directive('angularValidator',
// Setup $watch on a single formfield
function setupWatch(elementToWatch) {

//Prevent to re-watch the element
if (elementToWatch.isWatchedByValidator){
return;
}
elementToWatch.isWatchedByValidator = true;

// If element is set to validate on blur then update the element on blur
if ("validate-on" in elementToWatch.attributes && elementToWatch.attributes["validate-on"].value === "blur") {
angular.element(elementToWatch).on('blur', function() {
Expand Down

0 comments on commit 3690ac0

Please sign in to comment.