var ctrl = {};
ctrl.primaryProgramStudies = [{
"name": "test0",
"id": 0
},
{
"name": "test1",
"id": 1
},
{
"name": "test2",
"id": 2
},
{
"name": "test3",
"id": 3
},
{
"name": "test4",
"id": 4
},
{
"name": "test5",
"id": 5
},
{
"name": "test6",
"id": 6
},
{
"name": "test7",
"id": 7
},
{
"name": "test8",
"id": 8
},
{
"name": "test9",
"id": 9
},
{
"name": "test10",
"id": 10
},
{
"name": "test11",
"id": 11
},
{
"name": "test12",
"id": 12
}
]
ctrl.primaryProgramStudiesSelected = [null, true, true, true, null, true, null, true, null, true, null, null, true]
ctrl.selectedValues = ctrl.primaryProgramStudies.filter(function(obj, index) {
return ctrl.primaryProgramStudiesSelected[index] === true
})
console.log(ctrl.selectedValues)