Skip to content

Instantly share code, notes, and snippets.

@yoren

yoren/scripts.js Secret

Created September 16, 2015 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoren/1df7509a875aa2cd4df5 to your computer and use it in GitHub Desktop.
Save yoren/1df7509a875aa2cd4df5 to your computer and use it in GitHub Desktop.
var app = angular.module('app', ['ngRoute', 'ngSanitize', 'slick']);
//...
//Content controller
app.controller('Content', ['$scope', '$routeParams', '$http', function($scope, $routeParams, $http) {
$http.get('wp-json/posts/?filter[name]=' + $routeParams.slug).success(function(res){
$scope.post = res[0];
document.querySelector('title').innerHTML = res.title + ' | AngularJS Demo Theme';
$http.get('wp-json/media?filter[post_parent]=' + res[0].ID).success(function(res){
if ( res.length > 1 ) {
$scope.media = res;
}
});
});
}]);
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment