@angular/platform-browser vs. @angular/platform-browser-dynamic

BrowserImportAngularBootstrapping

Browser Problem Overview


In the newer examples (seeds, angular.io,..) there is an another import for the bootstrapping process: @angular/platform-browser-dynamic.

Could someone explain, what are the differences between it and @angular/platform-browser?

There is no information on the official angular.io website yet.

Browser Solutions


Solution 1 - Browser

The difference between platform-browser-dynamic and platform-browser is the way your angular app will be compiled.

Using the dynamic platform makes angular sending the Just-in-Time compiler to the front-end as well as your application. Which means your application is being compiled on client-side.

On the other hand, using platform-browser leads to an Ahead-of-Time pre-compiled version of your applicatiion being sent to the browser. Which usually means a significantally smaller package being sent to the browser.

The angular2-documentation for bootstrapping at <https://angular.io/docs/ts/latest/guide/ngmodule.html#!#bootstrap> explains it in more detail.

Solution 2 - Browser

  • platform-browser contains code shared for browser execution (DOM thread, WebWorker)
  • platform-browser-dynamic contains the client side code that processes templates (bindings, components, ...) and reflective dependency injection

When the offline template compiler is used, platform-browser-dynamic isn't necessary anymore because all reflective access and metadata are converted to generated code.

If you still want to dynamically generate components like shown in https://stackoverflow.com/a/36017067/217408 then you need the dynamic stuff.

Solution 3 - Browser

If you look closely at the history of the angular2 then you will find there are two version 1) beta version 2) release candidate version. At present it is r.c 3 (release candidate 3). Release candidate version means bug fix releases before the final release. So when angular2 moves to first release candidate version(rc1) from beta version then it make some directory change... for example

angular2/core---->@angular/core
angular2/platform/browser------>@angular/platform-browser-dynamic

I add a snape here enter image description here

for more information please visit

https://github.com/angular/angular/blob/master/CHANGELOG.md

i Hope you will find your answer. Thanks

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser2227400View Question on Stackoverflow
Solution 1 - BrowserniliuzView Answer on Stackoverflow
Solution 2 - BrowserGünter ZöchbauerView Answer on Stackoverflow
Solution 3 - BrowserhimadriView Answer on Stackoverflow