[英]how to use ng-checked inside a uib-tabset
With the example of ng-checked as documented at:- 以ng-checked为例,记录在: -
https://docs.angularjs.org/api/ng/directive/ngChecked https://docs.angularjs.org/api/ng/directive/ngChecked
If you place the first checkbox of 'check me to check both', the checkbox is not checked if it is placed inside a uib-tabset-heading after you have selected it. 如果您放置“选中我同时检查两者”的第一个复选框,则在您选择它后,如果它被放置在uib-tabset标题内,则不会选中该复选框。
Can anyone explain why this is the case and what you can do to persist the checked state. 任何人都可以解释为什么会这样,以及你可以做些什么来坚持检查状态。
It is a scoping issue. 这是一个范围问题。 The uib-tabset
directive creates a child scope for the tabs. uib-tabset
指令为选项卡创建子范围。 For prototypical inheritance to work properly the ng-model
directive needs to specify a property of an object. 为了使原型继承正常工作, ng-model
指令需要指定对象的属性。
<input ng-init='obj={}' id="checkSlave" type="checkbox" ng-checked="obj.master">
<br>
<uib-tabset active="active">
<uib-tab index="0" heading="Static title">
<label>Check me to check both:
<!-- Always include a dot in ng-model-->
<input type="checkbox" ng-model="obj.master"></label><br/>
</uib-tab>
The DEMO on PLNKR PLNKR上的DEMO
For more information, see The Nuances of Scope Prototypal Inheritance 有关更多信息,请参阅范围原型继承的细微差别
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.