0

I have some kind of repeat (its actually the grid-api that loops among elements). For each row I print a checkbox. In grid-api the element is referred as row.entity. Which is a json object.

Now, Im setting the ng-model equals to the id, like this:

ng-model="row.entity.id" 

I also print that ID on the screen, and it is a number. The ng-click looks like this:

ng-click="grid.appScope.addToQueue(row.entity.id, $event)"  

The function that handles the ng-click is this:

scope.addToQueue = function(id, $event){
     var element = angular.element($event.target);
     console.log("element:",element);
     console.log("id:",id);
  } 

The problem is that on the screen a number is printed. But as soon as I click in the checkbox, the value becomes a boolean, true or false. How can I get the actual number?
In the console it is the same problem. The boolean is printed.

1 Answer 1

2

You should probably use data-ng-true-value and its counterpart data-ng-false-value.

E.g.

<input type="checkbox" ng-model="row.entity.id"  data-ng-true-value="1" data-ng-false-value="0" />

This is also very well documented on their documentation page. Take a closer look here.

Sign up to request clarification or add additional context in comments.

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.