Skip to content

Instantly share code, notes, and snippets.

@amielucha
Last active October 10, 2015 15:54
Show Gist options
  • Select an option

  • Save amielucha/cabb7573b9eff1969030 to your computer and use it in GitHub Desktop.

Select an option

Save amielucha/cabb7573b9eff1969030 to your computer and use it in GitHub Desktop.
AngularJS ♥ WordPress Tutorial part 7 #tutorial
(function(){
var app = angular.module('angular♥wp', ['ngRoute']);
var api = {};
// JSON content location
api.query = 'http://amielucha.com/wp-json/wp/v2/posts/';
app.config(function($routeProvider, $locationProvider){
// Enable html5 mode
$locationProvider.html5Mode(true);
// configure routing
$routeProvider.when('/', {
templateUrl: 'content.html',
controller: 'Main',
});
});
app.controller('Main', ['$scope', '$http', '$routeParams', function($scope, $http, $routeParams){
$http.get( api.query ).success(function(res){
$scope.posts = res;
console.log($scope.posts);
});
}]);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment