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?
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?
Share Improve this question asked Jul 25, 2014 at 3:41 Sethe23Sethe23 2,6624 gold badges20 silver badges18 bronze badges1 Answer
Reset to default 12ng-true-value="sure"
. So, 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