Can someone explain the connection?

32 views
Skip to first unread message

Carlo Robazza

unread,
Feb 25, 2015, 4:09:30 PM2/25/15
to ang...@googlegroups.com
Hi there,

Unfortunately I'm new to MVC, Java and Angular but I've been tasked with working on an existing application.

I've tracked a bug down and I know what is happening and why but I have a disconnect between 2 pieces of code. I'm sure I'm missing one key piece of information that would clear it all up for me and I'm hoping when I describe the issue, someone can clear it up for me.

There is a controller javascript file with the following snippet of code:

else if ($scope.selectedItem == 1) {

                    $scope.newScoreTableValue.questionnaireQuestionID = $scope.questionTempId;

                    $scope.newScoreTableValue.responseType = $scope.selectedItem;

                    $scope.newScoreTableValue.responseShortForm = "Yes";

                    $scope.newScoreTableValue.responseValue = $scope.valueyes;

                    $scope.loading = true;

                    $http.post('/api/QuestionResponse/', $scope.newScoreTableValue).success(function (data) {

The post calls the following method:

        // POST api/<controller>

        public QuestionnaireQuestionResponses Post(QuestionnaireQuestionResponses response)

        {

            return _QuestionRepository.SaveQuestionResponse(response);

        }


My disconnect is that I can't figure out where the response object is coming from. When I step through the code I go from the $http.post to the Post(...) method. There is a value in the response object I need to set. Is there some intermediate step that I'm missing?

I'm hope this is enough to go on. I'm hoping someone will see this and say, "Oh, you need to look for ..."


Thanks,


Carlo.

Sander Elias

unread,
Feb 26, 2015, 12:02:35 AM2/26/15
to ang...@googlegroups.com

Hi Carlo,

I need to assume a lot here, so I might be off.
Under the assumption that your server routes the /api/QuestionResponse/ to your public QuestionnaireQuestionResponses Post(QuestionnaireQuestionResponses response), The data flow does indeed go from the $http call via your servers router to your server function. If you look up the documentation of $http you will likely get an answer to your question.

It boils down to this, If you want to add content, you need to put it in $scope.newScoreTableValue, if you want to add anything else (usually headers) you need to add it to the config of your $http call.

Does that help a bit?

Regards
Sander

Carlo Robazza

unread,
Feb 26, 2015, 9:53:16 AM2/26/15
to ang...@googlegroups.com
Is there some step between the http call and the Post(...) method? The newScoreTableValue object does not match the response object in the Post(...) so I'm thinking there must be some translation going on in between. Your thoughts?


Thanks,

Carlo.

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/eup7x7WQhwg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Sander Elias

unread,
Feb 26, 2015, 10:59:34 AM2/26/15
to ang...@googlegroups.com

Hi Carlo,

Usually a response object is an object that contains the payload, with the payload being the newScoreTableValue.

Regards
Sander

Reply all
Reply to author
Forward
0 new messages