Angular: Empty Fiddle
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
{{data}}
</div>
JavaScript
var myApp = angular.module('myApp', []);
var data = {
foo: 'bar',
baz: 'spam',
some_array: [1, 2, 3]
};
// JSFiddle's /echo/json/ service wants a x-www-form-urlencoded form. AngularJS does not do this
// by default.
function MyCtrl($scope, $http) {
console.log('json=' + encodeURIComponent(angular.toJson(data)));
$http.post('/echo/json/', 'json=' + encodeURIComponent(angular.toJson(data)), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}
}).success(function(data) {
$scope.data = data;
});
}