Controller Page
$scope.page = {
'1' : "small",
'2' : "large",
'3': "medium"
};
$scope.form.appraisal_id = "abc123";
$scope.form.user_id = "efg123";
for(var prop in $scope.page){
$scope.form.question_id = prop;
$scope.form.answer = $scope.page[prop]
console.log($scope.form);
appraisalService.saveForm($scope.form,function(result){
$scope.sent=result
console.log($scope.sent)
});
};
My Result
Object {appraisal_id: "abc123", user_id: "efg123", question_id: "1", answer: "small"}
Object {appraisal_id: "abc123", user_id: "efg123", question_id: "2", answer: "large"}
Object {appraisal_id: "abc123", user_id: "efg123", question_id: "3", answer: "medium"}
Resource {__v: 0, appraisal_id: "abc123", user_id: "efg123", question_id: 3, answer: "medium"…}
Resource {__v: 0, appraisal_id: "abc123", user_id: "efg123", question_id: 3, answer: "medium"…}
Resource {__v: 0, appraisal_id: "abc123", user_id: "efg123", question_id: 3, answer: "medium"…}
Expecting output
Object {appraisal_id: "abc123", user_id: "efg123", question_id: "1", answer: "small"}
Object {appraisal_id: "abc123", user_id: "efg123", question_id: "2", answer: "large"}
Object {appraisal_id: "abc123", user_id: "efg123", question_id: "3", answer: "medium"}
Resource {__v: 0, appraisal_id: "abc123", user_id: "efg123", question_id: 1, answer: "small"…}
Resource {__v: 0, appraisal_id: "abc123", user_id: "efg123", question_id: 2, answer: "large"…}
Resource {__v: 0, appraisal_id: "abc123", user_id: "efg123", question_id: 3,answer: "medium"…}