I'm writing my first application in AngularJS, and I'm new to javascript. I have a simple question:
How do I use POST values from an html form in an angular controller?
I have a form (i've stripped out the css and validation stuff for ease of reading):
<form name="signupForm" novalidate>
<input type="text" placeholder="Name..." ng-model="name" name="name" required />
<input type="email" name="email" ng-model="email" placeholder="Email..." required>
<input type="password" placeholder="Password..." ng-model="password" name="password" required ng-minlength="7" ng-maxlength="50"/>
<button type="button" ng-click="auth.signup()">Sign Up</button>
</form>
I have a controller (no errors), with a function which looks a bit like this:
function SignupController($http, $scope, $rootScope, $location) {
vm.signup = function(name, email, password, onSuccess, onError) {
$http.post('http://myapi.com/api/authenticate/signup',
{
name: name,
email: email,
password: password
}).then(function(response) {
// etc
});
}
Now, how do I assign the values name, email, password from the form to name, email, password in the controller?
Thanks.