Search code examples
angularjsangular-ngmodel

Get checkbox value instead of true of false in angularjs


I have the below checkbox code and i have to get value instead of true and false when it is selected.

<input type='checkbox' value="Athlete" ng-model="p.selected">

In the console p.selected displays true or false but i need value which is Athlete.How to change it?


Solution

  • You can use ng-true-value="'Athlete'" ng-false-value="'not Athlete'" to achieve this.

    You can find more information here.