This is a simple AngularJS module that uses PJAX to load HTML content from a server, compiles it, and then inserts it into the DOM.
It depends on AngularJS, jQuery, and PJAX.
Here is a basic setup with a Rails backend:
In your JavaScript:
var myApp = angular.module('myApp', ['ngPJAX']);
In your application layout:
<body ng-app="myApp" ng-class="{ contentLoading: loading }">
<div role="main" pjax-container>
<%= yield %>
</div>
</body>
In your application controller:
class ApplicationController < ActionController::Base
layout :layout_for_request
private
def layout_for_request(default_layout = 'application')
request.headers['X-PJAX'] ? false : default_layout
end
end