I have spent a lot of time making this work but in vane.
I would appreciate if someone could pin point me to the right direction.
I have created a sample code which can be found in Plunker here
I have spent a lot of time making this work but in vane.
I would appreciate if someone could pin point me to the right direction.
I have created a sample code which can be found in Plunker here
From ngRepeat doc:
The ngRepeat directive instantiates a template once per item from a collection. Each template instance gets its own scope
The trick is to add controlChecked
to form
and remove the ng-init
. So they will be in the same scope.
<div ng-show="control.type == 'Checkbox'">
<input type="checkbox" ng-model="form.controlChecked" name="{{control.id}}"/>
</div>
<div ng-show="control.type == 'DropdownList'">
<select ng-model="control.id"
ng-disabled="!form.controlChecked"
ng-options="value.code as value.name for value in control.items"
name="{{control.id}}"
>
</select>
Demo
from http://docs.angularjs/api/ng.directive:ngRepeat:
The ngRepeat
directive instantiates a template once per item from a collection. Each template instance gets its own scope.
so it looks like you should use the $parent
scope: $parent.controlChecked
.