Skip to content

Instantly share code, notes, and snippets.

@yoren
Last active August 23, 2016 04:59
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/99f2f2f8887eeb75eeb2 to your computer and use it in GitHub Desktop.
Save yoren/99f2f2f8887eeb75eeb2 to your computer and use it in GitHub Desktop.
Making WordPress Admin Bar Work With AngularJS Theme
<!DOCTYPE html>
<html>
<head>
<base href="/jsonapi/">
<title>AngularJS Demo Theme</title>
<?php wp_head(); ?>
</head>
<body>
<div id="page" ng-app="app">
<header>
<h1>
<a href="<?php echo site_url(); ?>">AngularJS Demo Theme</a>
</h1>
</header>
<div ng-view></div>
<footer>
&copy; <?php echo date( 'Y' ); ?>
</footer>
</div>
<?php wp_footer(); ?>
</body>
</html>
<search-form></search-form>
<ul>
<li ng-repeat="post in posts">
<a href="blog/{{post.ID}}" ng-bind-html="post.title"></a>
<div ng-bind-html="post.content"></div>
</li>
</ul>
var app = angular.module('app', ['ngRoute', 'ngSanitize']);
//Config the route
app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when('/', {
templateUrl: myLocalized.partials + 'main.html',
controller: 'Main'
})
.when('/blog/:ID', {
templateUrl: myLocalized.partials + 'content.html',
controller: 'Content'
})
.otherwise({
redirectTo: '/'
});
}]);
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment