angular.module('angularValidator', []);
angular.module('angularValidator').directive('angularValidator', ['$injector', '$parse', '$compile',
function($injector, $parse, $compile) {
return {
restrict: 'A',
link: function(scope, element, attrs, fn) {
var getRandomInt = function() {
return Math.floor((Math.random() * 100000));
};
// For this directive to work the form needs a name attribute as well as every input element.
// This function will add names where missing
var need_to_recompile = false;
// Iterate through all the children of the form element and add a `name` attribute to the ones
// that are missing it.
angular.forEach(element.find('input,select,textarea'), function(child_element) {
child_element = $(child_element);
if (!child_element.attr('name')) {
child_element.attr('name', getRandomInt());
console.log('WARNING! AngularValidator -> One of your form elements(,