I have a modal with two input fields and I'm trying to give an ng-class
to the form-group
if $invalid
on submit.
For that, I'm doing:
<div class="form-group" ng-class="{ 'has-error': item.answer[field2].$invalid }">
<label>{% verbatim %}{{ model.structure.field2 }}{% endverbatim %}</label>
<textarea name="answer[field2]" class="form-control"
ng-model="model.answer.field2" ng-required="true">
</textarea>
</div>
Keeping in mind that I need to keep the name answer[field2]
unless it's the only way, is there a workaround for the brackets?
Also tried answer[field2].$invalid
, item.answer[field2].$invalid
and item.answer.field2.$invalid
, but din't work.