I have an angularJS form which posts data to a scalatra servlet. When the form gets submitted I can't get any form params in my scalatra servlet.
Below is my code
AngularJS
$scope.createUser = function() {
$http.post('/createUser',{name:$scope.name,email:$scope.email,pwd:$scope.pwd}).
success(function(data, status, headers, config) {
alert("success " + data)
}).
error(function(data, status, headers, config) {
alert("failure =>" +data)
});
}; });
};
HTML form
<form ng-controller="UserController">
<legend>Create User</legend>
<label>Name</label>
<input type="text" id="name" name="name" ng-model="name" placeholder="User Name">
<label>Email</label>
<input type="text" id="email" name="email"
ng-model="email" placeholder="ur email here">
<label>Password</label>
<input type="text" id="pwd" name="pwd"
ng-model="pwd" placeholder="ur own pwd here">
<button ng-click="createUser()" class="btn btn-primary">Register</button>
</form>
Scalatra Servlet
post("/createUser") {
println(params("name"))
}
When I run the app and try to submit from the form I get this error
Error 500 key not found: name (obtained from firebug lite)
Please let me know if Iam missing something or anyother way to do this