Skip to content

Instantly share code, notes, and snippets.

@yoren
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yoren/9a197f7fe9eec45afdec to your computer and use it in GitHub Desktop.
Save yoren/9a197f7fe9eec45afdec to your computer and use it in GitHub Desktop.
Setting Page Title Dynamically In AngularJS WordPress Theme
//...
//Main controller
app.controller('Main', ['$scope', '$http', function($scope, $http) {
$http.get('wp-json/posts/').success(function(res){
$scope.posts = res;
document.querySelector('title').innerHTML = 'Home | AngularJS Demo Theme';
});
}]);
//Content controller
app.controller('Content', ['$scope', '$routeParams', '$http', function($scope, $routeParams, $http) {
$http.get('wp-json/posts/' + $routeParams.ID).success(function(res){
$scope.post = res;
document.querySelector('title').innerHTML = res.title + ' | AngularJS Demo Theme';
});
}]);
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment