admin管理员组文章数量:1026989
- I'm trying to display on screen html controls using Meta-Data stored in json file.
- Also I'm trying to create a state where pressing check box that will make a drop down disabled.
- I was managed to achieve this for a select box with static options and a select box with dynamic options (using ng-options).
- I could not achieve this when wrapping it with ng-repeat.
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'm trying to display on screen html controls using Meta-Data stored in json file.
- Also I'm trying to create a state where pressing check box that will make a drop down disabled.
- I was managed to achieve this for a select box with static options and a select box with dynamic options (using ng-options).
- I could not achieve this when wrapping it with ng-repeat.
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
Share Improve this question asked Aug 7, 2013 at 5:16 ScriptionScription 6453 gold badges12 silver badges21 bronze badges 02 Answers
Reset to default 1From 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
.
- I'm trying to display on screen html controls using Meta-Data stored in json file.
- Also I'm trying to create a state where pressing check box that will make a drop down disabled.
- I was managed to achieve this for a select box with static options and a select box with dynamic options (using ng-options).
- I could not achieve this when wrapping it with ng-repeat.
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'm trying to display on screen html controls using Meta-Data stored in json file.
- Also I'm trying to create a state where pressing check box that will make a drop down disabled.
- I was managed to achieve this for a select box with static options and a select box with dynamic options (using ng-options).
- I could not achieve this when wrapping it with ng-repeat.
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
Share Improve this question asked Aug 7, 2013 at 5:16 ScriptionScription 6453 gold badges12 silver badges21 bronze badges 02 Answers
Reset to default 1From 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
.
本文标签: javascriptAngularjs Make drop down disabled when pressing checkbox inside ngrepeatStack Overflow
版权声明:本文标题:javascript - Angularjs Make drop down disabled when pressing checkbox inside ng-repeat - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745660787a2161877.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论