Last active
December 26, 2016 10:10
-
-
Save xjinza/1896dda70cc1d10ea55069c358df71c1 to your computer and use it in GitHub Desktop.
angular http ajax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {}; | |
} | |
} ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment