I have a form declared in the html file. The inputs are generated dynamically.
That means, they are built as strings in javascript and then compiled inside a custom directive in angular.
app.directive('customInput', function($compile){
return{
restrict: 'E',
scope: true,
link: function(scope, element, attrs){
var html = "<input type='text' ng-model='tCtrl.test[$index]' ng-required='required' ng-maxlength='3'/>";
var el = $compile(html)(scope);
element.html("");
element.append(el);
}
}
});
They work fine with my angular code, but the problem is: They are not "recognized" as part of my form. That means, the parent FORM element does not change it's $pristine, $error, etc, status when inputs are modified.
How can I have the compiled inputs be treated as part of the form?
This plunkr is an example of the problem I'm having:
element.append.