JSFiddle - React, Tailwind, and code Playground

by Daniel Lamb

HTML

<div ng-app="myApp">
    <div ng-controller="Example">
        <button ng-click="post()">Post</button>
    </div>
</div>

JavaScript

angular.module('myApp', [])
.controller('Example', ['$http', '$scope', function ($http, $scope) {
    $scope.post = function(e) {
        $http.post('/echo/json/',
          // data to post to the server
          { foo: 'bar' }
        )
        .success(function(data, status, headers, config) {
          console.log('success', data);
        })
        .error(function(data, status, headers, config) {
          console.log('error');
        })
        .finally(function(data, status, headers, config) {
          console.log('finally');
        });
    };
}]);