1

I faced the following functions (or method I don't what is right name of the ):

function getRowArray($scope, object, i){    
  i = i + 1;
  var item = {};
  var data = [];
  var id = -1;    

  if ($scope.selectedType !== undefined) {
    id = $scope.selectedType.id;
  }    

  var rating = getRating($scope, object, id);    
  item['name'] = $scope.objectInfo[object]['name'];
  item['objectId'] = rating.objectId;
  item['hideRating'] = parseInt($scope.objectInfo[object].hideControls) & 1;   
  item['addInfo'] = rating.addInfo;   
  item['rating'] = rating.value;    
  item['ratingId'] = rating.id;

  for (var i in $scope.objectInfo[object].childs) {        
    if ($scope.objectInfo[object].childs[i] == object){
        continue;
    }

    data.push(getRowArray($scope, $scope.objectInfo[object].childs[i], i));
  }    
  item['data'] = data;
  return item;
}

and

function getTypeRow($scope, oobject, otype){

  var item = {};
  var data = [];
  var rating = getRating($scope, oobject.id, otype.id);

  item['name'] = otype.name;
  item['objectId'] = rating.objectId;
  item['typeId'] = rating.typeId;
  item['ratingId'] = rating.id;
  item['addInfo'] = rating.addInfo;
  item['rating'] = rating.value;
  // item['hideRating'] = parseInt($scope.objectInfo[object].hideControls);

  return item;
}

I want to use the hideRating item from the first one in the second, I tried and added the commented line but I got an error it says the object is undifined, is it wrong like that or am I missing something ? thanks in advance

2
  • 3
    Well, you're spelling it oobject in your arguments list, but you're calling the function on an object. Maybe that's the issue? Commented Jan 29, 2016 at 23:09
  • the error is in the line i have added Commented Jan 29, 2016 at 23:27

1 Answer 1

1

object is undefined because it wasn't initialized; it's not specified in the parameter list for the function getTypeRow. The oobject in the parameter list should be corrected to object:

// Correct 'oobject' to 'object'
function getTypeRow($scope, object, otype){

  var item = {};
  var data = [];
  // Correct 'oobject' to 'object'
  var rating = getRating($scope, oobject.id, otype.id);

  ...
}
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.