AngularJS object is null when passed to REST web service -
Angular newbie and I have no luck under this part. I try to send an update call to my rental web service I am passing and int and an object when debugging back to the web service, the int gets cured, though always the incoming object is in the form of a tap, debugging before the call shows that the object's The value is. Why am I getting newbies for my object in web service?
I have tried to call from a factory as well as save the function. When the web service is called, then both are null
app.js
Tournament Director App.factory ('tournamentFactory', function () {return { AddUserToTournament: Function (id, tournament, user, tournament) {tourney.Users.push (user) var response = tournament.update ({id: id}, {tournament: tournaments}) return trip;}};}); $ Scope.save = function {var updated tournaments = tournamentfitter.ADUSRTO tournaments (ID, selectedTourney, $ scope. Selected user, tournament); Tournament.update ({id: id}, {tournament: update tournaments}, function () {$ location.path ('/')}); };
Web service
public HTTPRPS Pacemats sheet (Int id, tournament tournament) {if ( ModelState.ISIIDID & amp = id == Tournament Tournament) {db.Entry (tournament) .set = Entitestate. Revised; Db.SaveChanges (); Return request. Cresparsons (HTTPPatus code.ak); } And {return request. Create Response (HTTPTas Code. Badrequest); }}
* tournament object *
public class tournament {public int tournament id {get; Set; } Public String Director {get; Set; } Public string description {get; Set; } Public Date Time? StartDate {Get; Set; } Public Date Time? End date {Received; Set; } Public Virtual List & lt; Classification & gt; Classification {receive; Set; } Public Virtual List & lt; Users & gt; User {Received; Set; }}
* app.js (routing for updates) *
Tournament Director Up.Fasinner ('Tournament' , Function ($ resource) {return $ resource ('/ api / tournament /: id', {id: 'id}', {update: {method: 'PUT'}});
Based on the "updates" example in the cooner docs, I think that The problem is that you should only send an updated tournament with update updates, and not change the object Try: (
/ Pre>
In your saved function.
Comments
Post a Comment