How to post form data to Server backend

47 views
Skip to first unread message

Stanley Mokwe

unread,
Jan 31, 2022, 1:22:31 AM1/31/22
to Angular and AngularJS discussion
I want the code below to be able to post form data to server backend. I know how to handle the PHP backend code. can someone help me out. Thanks


<html>
   <head>
      <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
     
 
     
   </head>
   <body>
     
      <div ng-app = "mainApp" ng-controller = "testController">
         
         <form name = "testForm">

<b>Firstname</b><br>
<input name = "firstname" type = "text" ng-model = "firstName" required>

<br>
<b>Lastname</b><br>
<input name = "lastname"  type = "text" ng-model = "lastName" required>

<br>
<b>Email</b><br>
<input name = "email" type = "email" ng-model = "email" length = "100" required>
<br><br>
  <button ng-click = "reset()">Reset</button>
<button ng-click="submit()">Submit</button>
</form>

                 
      </div>
     
      <script>
         var mainApp = angular.module("mainApp", []);
         
         mainApp.controller('testController', function($scope) {
            $scope.reset = function() {
//addrecord.php;

               $scope.firstName = "Ann";
               $scope.lastName = "Joyce";
               $scope.email = "my email goes here";
            }
           
            $scope.reset();
         });
      </script>
     
   </body>
</html>
Reply all
Reply to author
Forward
0 new messages