0

I have to show error for each row in a List.

HTML code

   <tr ng-repeat="model in models">
     <td>
      <div role="alert">
       <span class="error" ng-show="errorField_{{models.indexOf(model)}}" translate="eror"></span>
      </div>
     </td>
   </tr>

ng-show errorField_1, errorField_2..... and so on...

Now how i can i get hold of ng-show variable in controller class ? Any clue for example if i want to change particular variable state. I dont know how to get hold of the dynamicity.

$scope.errorField_12 = false;
1
  • try ng-show=" 'errorField_' +{{models.indexOf(model)}} " Commented Nov 22, 2015 at 10:47

1 Answer 1

1

Instead of declare seprate variable in scope.

Try to use property in models

Like this

   <tr ng-repeat="model in models">
     <td>
      <div role="alert">
       <span class="error" ng-show="model.isError" translate="eror"></span>
      </div>
     </td>
   </tr>

Make isError true or false to show/hide

Like you wanna to show first item's error

$scope.models[0].isError = true;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.