Validation of form in generated fields with ng-messages

Over the course of the day, I worked with form validation to work with new ng messages in generated fields without success. I read in the angular documentation and on github issue ng-repeat is not supported by ng messages because it does not interpolate its fields. So, I decided to switch to jquery route build, so that I myself compiled it and replaced the element with my generated code, which, of course, I can’t work either. So some help would be greatly appreciated. Here is my html:

....
    <app-field ng-repeat="field in fields" field="field" ng-model="selected[field.name]" form="form" type="input"></app-field>

    <fieldset class="form-group">
        <label for="field1s">static field 1</label>
        <input name="field1s" type="text" ng-model="selected['field1']" class="form-control" required="">
        <ng-messages for="form['field1'].$error">
            <ng-message when="required">Is required</ng-message>
        </ng-messages>
        <label for="field2s">static field 2</label>
        <input name="field2s" type="text" ng-model="selected.field2" class="form-control" required="" ng-maxlength="10" ng-minlength="2">
        <ng-messages for="form.field2s.$error">
            <ng-message when="required">Is required</ng-message>
            <ng-message when="maxlength">Max length 10</ng-message>
            <ng-message when="minlength">MIn length 2</ng-message>
        </ng-messages>
    </fieldset>

, . app-field dom, jQuery, , . , dom , , ... angular, angular , . , , ng- : Angularjs: , . , . plunk: http://plnkr.co/edit/ZzC4jS9M9Ev5i6gxUVxB?p=preview

...

+4
1

ng-form ng-repeat . 1. http://plnkr.co/edit/xQTLDa3TptXky8KIcSsh?p=preview

<form name="form">

<ng-form name="myform">
    <input name="field1s" type="text" ng-model="selected['field1']" class="form-control" ng-required="true" ng-pattern="/^[0-9a-zA-Z]+$/">
            <ng-messages for="form.myform['field1s'].$error">
                <ng-message when="required">Is required</ng-message>
                <ng-message when="pattern">alpha error </ng-message>
            </ng-messages>
</ng-form>

</form>

JQuery, . .

. https://github.com/angular/angular.js/issues/10165. .

+1

All Articles