Example AngularJS Post

Shows an example of how to do a "normal" POST with AngularJS' $http service

by Sean Coyne

HTML

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<p ng-controller="ItemListCtrl">{{data}}</p>

JavaScript

function ItemListCtrl($scope, $http) {
    $scope.data = "";
    $http.post("/echo/json/",$.param({
        json: angular.toJson("hello, world!")
    }),{
        headers: {'Content-Type': 'application/x-www-form-urlencoded'} 
    }).success(function(data) {
        $scope.data = angular.fromJson(data);
    });
}