[英]AngularJS checkbox checked custom value
I'm trying to have a box checked by default with a custom value. 我正在尝试使用自定义值检查一个框。
Are you ready? <input type="checkbox" ng-model="checked" ng-init="checked=true" ng-true-value="sure" ng-false-value="nope"><br/>
<tt> {{checked}}</tt><br/>
If I set it to that nothing displays until I click the box. 如果我将其设置为在我单击该框之前不显示任何内容。 Is there a way to where it can be checked with a default value being something other than a boolean value?
有没有办法可以检查默认值是否为布尔值以外的其他值?
ng-true-value="sure"
. ng-true-value="sure"
。 So, ng-init="checked='sure'"
所以,
ng-init="checked='sure'"
Code Snippet 代码片段
<input type="checkbox" ng-model="checked" ng-init="checked='sure'" ng-true-value="sure" ng-false-value="nope">
Plunkr - http://plnkr.co/edit/ejYSsyIjMZSZua9cQyv1?p=preview Plunkr - http://plnkr.co/edit/ejYSsyIjMZSZua9cQyv1?p=preview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.