0

I have a list called positions that has N positions in them. I also have a user user that has an attribute user.positions that has some of the positions assigned to.

I want to show a form with all the possible positions, and the positions that the user already has to be checked.

Is this something I can do inside the HTML, or do I need to loop through both in my logic and create a new variable?

1 Answer 1

2
<label ng-repeat="position in positions">
  <input type="checkbox" ng-checked="user.positions.indexOf(position) != -1" /> {{position}}
</label>

http://jsfiddle.net/t4ZQd/

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

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

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.