Hi I am trying to post data with AnguarJs but having some issues.My js code is below :
var app = angular.module('myApp', []);
app.constant('appUrl', 'http://localhost/zara/rest/');
/*---- categories fetch code -------*/
app.controller('myController',['$scope','$http','appUrl', function($scope, $http , appUrl) {
$scope.newName = "";
$scope.postForm = function() {
var data = $.param({
name: $scope.newName
});
$http.post("http://localhost/zara/rest/api_customerlogin.php", data).success(function(data, status) {
$scope.hello = data;
console.log(data);
});
};
}]);
I am getting this error TypeError: Cannot read property 'param' of undefined
And when i change code to like this one then i got this error.
<script>
angular.module('myApp', [])
.controller('myController', ['$scope', '$http', function($scope, $http) {
this.loginForm = function() {
var user_data='user_email=' +this.inputData.email+'&user_password='+this.inputData.password;
$http({
method: 'POST',
url: 'login.php',
data: user_data,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
})
.success(function(data) {
console.log(data);
})
}
}]);
</script>
Cannot post to login.html page.This is my first project on AnguarJs so not very familer with this.Thanks.