JSFiddle - React, Tailwind, and code Playground
by trolleymusic
HTML
<div ng-app="myApp">
<div ng-controller="GreetingController">{{ greeting }}</div>
</div>
JavaScript
var myApp = angular.module('myApp', []);
myApp.service('HTTPService', ['$http', function ($http) {
this.getPage = function (slug) {
return $http.get('wordpress/api/get_page/?slug=' + slug)
}
}])
myApp.controller('GreetingController', ['$scope', 'HTTPService', function ($scope, HTTPService) {
return
HTTPService.getPage('home')
.success(function (data) {
$scope.page = data.page;
console.log(arguments);
})
.error(function () {
console.log(arguments);
})
}]);
var url = 'wordpress/api/get_page/?slug=home',
request = new XMLHttpRequest()
request.open('get', url)
// Handle the response
request.onload = function() {
console.log('Response', request.response)
}
// Handle errors
request.onerror = function(error) {
console.log('Error', error)
}
// Make the request
request.send()