I have also been looking at this.
From my current understanding, with Angular 2 we would use the so called "long form bootstrap".
In essence it means one would bootstrap multiple Angular 2 components in the page.
<my-app></my-app>
<div style="margin: 40px">
Some server generated content.
</div>
<my-greeting></my-greeting>
This an example of doing long form bootstrap.
This is part of my personal experiments, it is not production ready code.
Should provide an idea of how to achieve this anyway.
import {Component, createPlatform, coreBootstrap, coreLoadAndBootstrap, ReflectiveInjector, ApplicationRef} from 'angular2/core';
import {BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS, browserPlatform} from 'angular2/platform/browser';
import {provide, enableProdMode} from "angular2/core";
import {bootstrap} from 'angular2/platform/browser';
import {HTTP_PROVIDERS} from "angular2/http";
import {ROUTER_PROVIDERS} from 'angular2/router';
import {APP_BASE_HREF, LocationStrategy, HashLocationStrategy} from 'angular2/platform/common';
import {provideStore, usePostMiddleware, usePreMiddleware, Middleware} from "@ngrx/store";
import 'rxjs/add/operator/do';
import {store} from "./common/store";
import {AppComponent} from './app.component'
import {DialogService} from './dialog.service';
import {GreetingComponent} from './greeting-component';
const actionLog: Middleware = (action: any) => {
return action.do((val: any) => {
console.warn("DISPATCHED ACTION: ", val);
});
};
const stateLog: Middleware = (state: any) => {
return state.do((val: any) => {
console.info("NEW STATE: ", val);
});
};
//var platform = browserPlatform();
var platform = createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PROVIDERS));
var appProviders: any[] = [
ROUTER_PROVIDERS,
HTTP_PROVIDERS,
provide(APP_BASE_HREF, {useValue: "/"}),
provideStore(store),
usePreMiddleware(actionLog),
usePostMiddleware(stateLog),
provide(LocationStrategy, { useClass: HashLocationStrategy }),
DialogService
];
var appInjector = ReflectiveInjector.resolveAndCreate([BROWSER_APP_PROVIDERS, appProviders], platform.injector);
var _appComponent = coreLoadAndBootstrap(appInjector, AppComponent);
var greetingProviders: any[] = [];
var greetingInjector = ReflectiveInjector.resolveAndCreate([BROWSER_APP_PROVIDERS, greetingProviders], platform.injector);
var _greetingComponent = coreLoadAndBootstrap(greetingInjector, GreetingComponent);
//
The AngularJS 1.x way was pretty convenient in this particular situation.
Nonetheless, it is perfectly achievable with Angular 2 as well.