angular http ajax
tips:from http://jsfiddle.net/tjsteinhaus/fo3y41rn/
var myControllers = angular.module( 'myControllers', [] );
myControllers.controller( 'FormController', function( $scope, $http, $httpParamSerializerJQLike ) {
$scope.master = {};
$scope.update = function( user ) {
$scope.master = angular.copy( user );
console.log( $scope.master );
$http( {
method: 'POST',
url: 'test.php',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
data: $httpParamSerializerJQLike({
'name': user.name,
'email': user.email,
'gender': user.gender
})
} ).success( function( data ) { console.log( data ); } );
}
$scope.reset = function() {
$scope.user = {};
$scope.master = {};
}
} );