There are two parts: firstly, you need to disconnect the router from loading the first page load. This can be done like this:
app.config(function($httpProvider, $urlRouterProvider) {
Secondly, we need to properly configure the ui-view. Resetting the markup created by the server inside the ui-view causes problems with strange behavior when the first controller is first started (see https://github.com/angular-ui/ui-router/issues/1807 ), so we will add our rendering server immediately after the ui-view div and hide the ui-view until a navigation event appears.
<div ng-controller="PropertyDetailCtrl"> <div class="ng-cloak" ng-show="!isFirstPageLoad" ui-view></div> <div ng-show="isFirstPageLoad"> (server rendered markup goes here) </div> </div>
Now we need to set isFirstPageLoad in the scope $ scope:
app.controller('PropertyDetailCtrl', function loader($rootScope, $scope) { $scope.isFirstPageLoad = true; $rootScope.$on('$viewContentLoading', function(event, viewConfig) { $scope.isFirstPageLoad = false; }); });
We used ng-cloak to make sure the page behaves fine if javascript is disabled, so now we have a full server-side loading of the first page with all subsequent navigation handled by ui-router.
source share