Created
June 17, 2011 16:45
-
-
Save vojtajina/1031783 to your computer and use it in GitHub Desktop.
Angular Simple POST using $xhr
This file contains hidden or 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
<!DOCTYPE HTML> | |
<html xmlns:ng="http://code.angularjs.org/0.9.16/angular-0.9.16.min.js" ng:controller="Main"> | |
<head> | |
<title>Simple Example of Angular's $xhr</title> | |
<script type="text/javascript" src="build/angular.js" ng:autobind></script> | |
<script type="text/javascript"> | |
function Main($xhr){ | |
var selft = this; | |
this.doRequest = function() { | |
$xhr('POST', 'url.php', 'data-content=233', function(code, response) { | |
self.response = response; | |
}); | |
}; | |
} | |
</script> | |
</head> | |
<body> | |
<a href ng:click="doRequest()">do POST request to url.php</a> | |
<div>{{response}}</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you have version of this but doing it in a service??
Good one!!