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>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/angular/0b481371-7fd7-4631-8b22-fe9dd817f962n%40googlegroups.com.