Corner JS flag set value

I am trying to set a default checkbox 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 the fact that nothing is displayed until I press the button. Is there a way so that it can be checked with a default value other than a boolean?

+6
source share
1 answer

ng-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

+9
source

Source: https://habr.com/ru/post/972809/


All Articles