0
<div class="col-md-12" data-ng-repeat="p in ['A1','A2','A3']">
    <div class="form-group col-md-6"  
    data-ng-class='{ "has-focus": form.model[p].hasFocus,
            "has-success": form.model[p].$valid,
            "has-error": form.model[p].$invalid && (form.$submitted || form.model[p].$touched),
            "is-empty": !form.model[p].$viewValue }'>
        <label for="model[p]">
        </label>
    <input
        type="text" name="model[p]"
        data-ng-model="p"
        data-ng-blur='form.model[p].hasFocus=false'
        data-ng-focus='form.model[p].hasFocus=true'
        data-ng-readonly="true" 
        style="text-align:center;" required >
        <p
        data-ng-show="form.model[p].$error.required && (form.model[p].$touched || submitted)"
        class="error-block">Error in policy</p>
    </div>
</div>

The above code generates 3 text box . The problem is when I click on one of the text box has-focus is getting applied but on removing the focus by clicking some where else on the page the has-success class is not getting applied.

I tried to replace [p] with different combinations like using {{p}} , _{{$index}}.

But none of them working fine for me .

Either I receive $parse syntax error in console or on clicking on one of the text box , other text box also gets focused.

I am trying very hard but not able to resolve this issue.

Any help is appreciated !!!

Thanks

shreyansh
  • 1,637
  • 4
  • 26
  • 46

0 Answers0