0

I have a html table which is binding using Angularjs.Now i want to select checkbox during ng-repeat with a condition.

<tbody>
                            <tr class="gradeX" ng-repeat="itm in usersList">

                                <td>
                                    <input type="checkbox"/></td>
                                <td> {{itm.FirstName}}</td>

                                <td>{{itm.Email}}</td>

                            </tr>
                        </tbody>

I have another field itm.checkstatus.i want to check the checkbox during ng-repeat when itm.checkstatus=1 then checkbox will check else checkbox will not check.how to do this?

1 Answer 1

1

You can use ng-checked for this:

https://docs.angularjs.org/api/ng/directive/ngChecked

 <tbody>
      <tr class="gradeX" ng-repeat="itm in usersList">
         <td><input type="checkbox" ng-checked="itm.checkstatus == 1" /></td>
         <td>{{itm.FirstName}}</td>
         <td>{{itm.Email}}</td>
      </tr>
  </tbody>
Sign up to request clarification or add additional context in comments.

3 Comments

thanks but i cant understand from this link.can you write this code for me
Thanks for help. i have used ng-checked="{{itm.checkstatus==1}}".and it is working fine.
The curly braces shouldn't be necessary

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.