Created
October 27, 2015 01:33
-
-
Save carbonrobot/dbeb9eda9c0fbd3a45bd to your computer and use it in GitHub Desktop.
Set $touched to true on click of submit button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('app.default').directive('ckValidateOnClick', ckValidateOnClick); | |
function ckValidateOnClick($compile) { | |
return { | |
restrict: 'A', | |
require: '^form', | |
link: function compile(scope, element, attrs, form) { | |
var col = element.parent('form').find('[name]'), | |
parts = form.$name.split('.'); | |
element.on('click', function () { | |
col.each(function (i, e) { | |
var ele = angular.element(e), | |
name = ele.attr('name'); | |
scope[parts[0]][parts[1]][name]['$touched'] = true; | |
}); | |
}); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment