9

I have a simple checkbox input

<input type="checkbox" name="xxx" data-ng-clik='someFunction(true/false)' "/>

If user tick checkbox I want to call my someFunction(true) with true value and if user uncheck I want to call the same function someFunction(false) with false value.

Any suggetions how can I do that?

2 Answers 2

11

You should call your method on ng-change of checkbox, to get correct changed value. Also add ng-model to get two way binding enable your checkbox value.

<input ng-model="myCheckbox" type="checkbox" name="xxx" 
       ng-change='someFunction(myCheckbox)'">
Sign up to request clarification or add additional context in comments.

Comments

0

you got to use ng-model in the checkbox field

<input type="checkbox" name="xxx" ng-model="value" data-ng-click='someFunction(true/false)' "/>

So in your function, you can get it by using $scope.value

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.