0

How can I concatenate a variable to the $scope model. I am trying to do something like this

for(var i=0;i<=response.length-1;i++)
{
   $scope.formData.jobId+i=response[i].jobId;
} 

How can I concatenate the variable i to $scope.formData.jobId so that it becomes $scope.formData.jobId1, $scope.formData.jobId2 and so one.

1 Answer 1

2

You can access it like this by dynamically constructing your property name and using it as a string

$scope.formData['jobId' + i] = response[i].jobId;
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.