I have this $scope.data object:
$scope.data = {
'8':{
'id':'81',
'name':'anna',
},
'9':{
'id':'82',
'name':'sally',
},
};
I am getting the id by using for loop in this way.
$scope.getID = function(id){
for(var i=0;i<$scope.data.length;i++){
if(id == $scope.data[i].id)
return $scope.data[i].name;
}
}
};
But it doesn't work at all. I am wondering why? Is it I call the id at the right way?