I'm trying to set a checkbox to true with Angularjs. Right now I'm cheating using vanilla javascript to manipulate the DOM, but I want to do it the right way with Angularjs.
Here is the view:
<div x-ng-repeat="addon in addons">
<label for="{{addon.addoncode}}">
<input type="checkbox"
name="{{addon.addoncode}}"
value="{{addon.addoncode}}"
id="{{addon.addoncode}}"
x-ng-model="addon.checked"
x-ng-click="checkAddonDependencies()" >
<span x-ng-bind-html="addon.addon_desc">{{addon.addon_desc}}</span> </label>
</div>
And here is the relevant part of the controller:
if (document.getElementById(dep)) {
document.getElementById(dep).checked=true;
}
The dep value is equal to the addoncode value, so if it exists I check the box. This works and checks the box but how could I do this using the scope instead?
I tried:
x-ng-model="addon.addoncode"
with
$scope.addon.dep = true;
But no luck... any help appreciated. Thanks.