html - Angular ng-messages inside custom directive inside ng-repeat wrong behaviour -
i have same problem described in toppic: angular js ng-message inside directive
unfortunatelly solutions not working me, because using custom directive inside ng-repeat. ng-messages work when error condition fulfilled inputs.
http://plnkr.co/edit/ljt48bmyvr9dgfliiydh?p=preview
i have tried many ways creating ng-messages condition nothing worked properly. 2 of them can find in above plunker:
ng-messages="form.doubleinputleft.$error" ng-messages="form['doubleinputright' + $index].$error"
please me, regards
for input
elements work inside ng-repeat
, index must included part of name attribute.
<!-- index must included in name attribute -- <input name="doubleinputleft" class="form-control ngmessagesample" type="{{inputtype}}" ng-model="modelleft" ng-minlength="2" ng-maxlength="20" required> --> <input name="doubleinputleft{{index}}" class="form-control ngmessagesample" type="{{inputtype}}" ng-model="modelleft" ng-minlength="2" ng-maxlength="20" required> <div ng-messages="form['doubleinputleft'+index].$error" class="ngmessagesclass" ng-messages-multiple> <div ng-message="minlength" class="ngmessageclass"> {{leftinputheading}} must have @ least 2 characters.</div> <div ng-message="maxlength" class="ngmessageclass"> {{leftinputheading}} must have @ 20 characters.</div> </div>
otherwise, repeated elements have duplicate names.
the demo on plnkr
Comments
Post a Comment