Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('far_login',[])
- .controller('far_formcontrol',['$scope','$http', function($scope, $http) {
- // function to submit the form after all validation has occurred
- $scope.submitForm = function() {
- console.log('First Name : ' , $scope.fname);
- console.log('Email : ' , $scope.email);
- console.log('Last Name: ', $scope.lname);
- // check to make sure the form is completely valid
- if ($scope.sform.$valid) {
- $http({
- url: 'http://localhost:8181/far_submit.php',
- method: 'POST',
- headers: {'Content-Type': 'application/x-www-form-urlencoded'},
- transformRequest: function(obj) {
- var str = [];
- for(var p in obj)
- str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
- return str.join("&");
- },
- data: {"name": $scope.fname, "email": $scope.email, "lname": $scope.lname}
- })
- .then(function(response) {
- console.log(response)
- })
- .catch(function (error) {
- console.log(error);
- });
- } else {
- alert('our form is not amazing');
- }
- };
- }]);
Add Comment
Please, Sign In to add comment