I have an Angular ui-select that is used to toggle some checkboxes (generated with ng-repeat
) based on the selected option.
The checkboxes can also manually be toggled as well, and that's where things seem to go wrong.
Scenario is as follows:
- Select an option. Some checkboxes are toggled based on the
ingredients
property of the specified option on the$scope.recipes.available
model. - Manually toggle an additional checkbox.
- Select a different option on the select. The corresponding checkboxes are correctly toggled.
- Switch back to the first selected option. Instead of only toggling the checkboxes originally specified on the
ingredients
property, the manually modified checkbox is also toggled. While debugging I see that somehow theingredients
property has been modified.
This plunkr demonstrates the problem.
So far, after reading countless scoping issues (I'm new to Angular) and trying again and again to refactor my code I haven't been able to fix this problem.
Before going ahead and trying to refactor the code one more time, I'd like to understand what's going on in here.
Why is the ingredients
property being modified?