Last active
August 29, 2015 14:15
-
-
Save yoren/9a197f7fe9eec45afdec to your computer and use it in GitHub Desktop.
Setting Page Title Dynamically In AngularJS WordPress Theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
//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