What's the difference between BrowserModule and platformBrowserDynamic?

前端 未结 3 2080
庸人自扰
庸人自扰 2021-02-06 10:05

What are the purposes of these two modules?

import { BrowserModule } from \'@angular/platform-browser\';
import { platformBrowserDynamic } from \'@angular/platfo         


        
3条回答
  •  爱一瞬间的悲伤
    2021-02-06 10:49

    platformBrowserDynamic is a function used to bootstrap an Angular application.

    CommonModule is a module that provides all kinds of services and directives one usually wants to use in an Angular2 application like ngIf. CommonModule is platform-independent.

    BrowserModule exports CommonModule and provides a few services specific to the browser platform (in contrary to ServerModule or ServiceWorkerModule).

    BrowserModule should only be imported in AppModule, CommonModule can be imported everywhere.

提交回复
热议问题