Hi there,
"If the parameter value is prefixed with @ then the value of that parameter is extracted from
the data object (useful for non-GET operations)."
I'm trying to submit form data to a jetty server.
I have a User service declared like this:
angular.service('User', function($resource){
return $resource('/api/users/:userId', {}, {
query: {method:'GET', params:{userId:'@id'}, isArray:true},
save: {method:'POST', params:{first:'@first', last:'@last', email:'@email', username:'@username', password:'@password', bio:'@bio'}}
});
});
I have a user registration form that looks like this:
<div ng:controller="UserCtrl">
<form ng:submit="newUser()">
<div><input maxlength="140" value="" placeholder="First Name" type="text" name="first" /></div>
<div><input maxlength="140" value="" placeholder="Last Name" type="text" name="last" /></div>
<div><input maxlength="140" value="" placeholder="Email" type="text" name="email" /></div>
<div><input maxlength="140" value="" placeholder="Username" type="text" name="username" /></div>
<div>
<div><input name="password" type="password" placeholder="Password" value="*******" /></div>
<div><input name="passwordAgain" type="password" placeholder="Password Again" value="*******" /></div>
</div>
<div><input value="" placeholder="Date of Birth" type="text" name="dateOfBirth" /></div>
<div><input maxlength="1028" value="" placeholder="Profile Pic" type="text" name="profilepic" /></div>
<div><textarea rows="10" placeholder="Bio" name="bio" cols="50"></textarea></div>
<div class="row">
<div class="span1">Cancel</div>
<div class="span1"><input type="submit" value="Create" /></div>
</div>
</form>
</div>
And I have a UserCtrl object that looks like this:
function UserCtrl(User_) {
var scope = this;
scope.newUser = function() {
User_.save({first:scope.first, last:scope.last, username:scope.username, email:scope.email, password:scope.password, bio:scope.bio});
}
}
When User_.save() is called, the web server receives a POST url that looks like this... /api/users?first=@first&last=@last&email=@email
Rather than evaluating @first, @last etc, these are being passed through as literals.
Any clue what I'm doing wrong?
thanks
Brent