I am venturing into the world of AngularJS and JavaScript for the first time with my new application. I have a straightforward query:
How can I access POST values from an HTML form within an Angular controller?
Here is the simplified version of my form (CSS and validation removed for clarity):
<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>
In my controller (devoid of errors), there is a function that somewhat resembles 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 link the form's name, email, and password values to the respective variables in the controller?
Appreciate any guidance.