Aceman Aceman - 13 days ago 6
Javascript Question

How to modify array with checkbox selection (It's ready just need to modify something)

I'll try to be short and get to the point.

When I choose a role, it adds it to an array with the role's name and whether it's selected or not (with true or false). Actually the array is saved the following way:

[
{
"name": "CDB_DBA",
"selected": true
},
{
"name": "CONNECT",
"selected": true
}
]


and I need it to be saved this way (with the roles I select from the checkbox list):

["CDB_DBA", "CONNECT"]


The array contains the selected roles, I'm sure it's pretty simple to change but I'm new to this and need some help. Thank you in advance. Here's the JSBin link to the project:

JSBin Project

Answer

I have updated your link by creating a new array and pushing the value into that array while checking the checkbox

Can you check this is expected? If not please explain it briefly.

please check the below link

http://jsbin.com/huwepirolo/edit?html,js,output

 $scope.updateArray= function(value){
      alert(value);
      $scope.array.push(value);
    }