I want to create a checkbox so that when a model value is a positive number it is checked, otherwise it is unchecked. I want it to also write to the model value when the user clicks on it. So that if the number was positive it becomes 0 and otherwise it becomes 1.
In other languages my approach would have been to use get/set methods to access the value where these methods would implement the above logic. Is there a way to do that in angular in a generic way (so not writing a directive/factory specific to this use case)? And, what is the proper way to solve this exact use case?
Turns out it is supported out of the box: https://docs.angularjs.org/api/ng/directive/ngModel#binding-to-a-getter-setter
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments