Issues passing data to be inserted to php backend

26 views
Skip to first unread message

Blessing Augustine

unread,
Nov 24, 2021, 9:46:57 AM11/24/21
to Angular and AngularJS discussion
Am trying to insert records to database using angular1. when I tried the code below.

It does not work. it seems the insert functions is not properly constructed. can someone help me out. its urgents

<body>
<div ng-app="myApp" ng-controller="myCtrl">
<form>
Name:<input type="text" ng-model="name" />
Email:<input type="text" ng-model="email" />
<input type="button" value="Submit" ng-click="addData()" />
</form>
</div>
<script>
    var app = angular.module('myApp',[]);
    app.controller('myCtrl',function($scope,$http){    
        $scope.adData=function(){      
            $http.post("test.php", {
                'name':$scope.name,
                'email':$scope.email
            }).then(function(response){
                    console.log("Data addes Successfully");
                },function(error){
                    alert("Data inserts failed");
                    console.error(error);

                });
            }
        });
    </script>

Blessing Augustine

unread,
Nov 24, 2021, 11:48:32 AM11/24/21
to ang...@googlegroups.com
I found out the Problem. The issue is with Typo Error.  its should be  $scope.addData  and not  $scope.adData. i omitted d letter.

Thanks all

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/0b481371-7fd7-4631-8b22-fe9dd817f962n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages