0

I'm trying to post changes to a row in a table via a form in AngularJS. However, it looks like the data selected in the view is not pushed to the object correctly, and I get a 500 error when posting on my real dev environment.

Here's my code

Edit:

The format I would like to post is: { "id" : "1", "name" : "5k", "distance" : "3.1 miles", "date" : "3/14/2014", "time" : "8 am" }

6
  • elaborate? What is the format you want? Commented Mar 10, 2014 at 17:24
  • The format I want when I post is: { "id" : "1", "name" : "5k", "distance" : "3.1 miles", "date" : "3/14/2014", "time" : "8 am" } Commented Mar 10, 2014 at 18:49
  • 1
    That is nothing like the format of your editedEvent content - you need to create a function that will convert the event into that sign up. May I suggest reformatting your input data so that it more accurately matches the format of your output, then you'll have much less confusion. Commented Mar 11, 2014 at 9:54
  • I created a convertor, but the editedEvent object doesn't seem to be holding all of the ng-model items in it (i.e. it's missing date, time, and id). So I was only able to convert "name" and "distance", since nothing else was getting passed in through the model. Here's my updated code Commented Mar 11, 2014 at 14:09
  • This question has been resolved in question 22328452. Thanks for your help Ed. Commented Mar 11, 2014 at 19:28

1 Answer 1

0

If I change your save button to run the save() method on the scope, then the following is the request payload to some/url.

{
   "name":{
      "type":"Afternoon",
      "_embedded":{
         "event":{
            "_links":{
               "self":{
                  "href":"www.example.com/events/shift/2"
               }
            },
            "name":"10k",
            "distance":"6.2 miles"
         }
      }
   }
}

This is exactly the same data as is in your scope. As such, I would suggest your server code is doing something wrong with the data..

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.