问题描述
这两个模块的目的是什么?
What are the purposes of these two modules?
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
推荐答案
platformBrowserDynamic
是用于引导Angular应用程序的函数.
platformBrowserDynamic
is a function used to bootstrap an Angular application.
CommonModule
是一个模块,提供通常在Angular2应用程序(如ngIf
)中使用的各种服务和指令. CommonModule
与平台无关.
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
导出CommonModule
并提供一些特定于浏览器平台的服务(与ServerModule
或ServiceWorkerModule
相反).
BrowserModule
exports CommonModule
and provides a few services specific to the browser platform (in contrary to ServerModule
or ServiceWorkerModule
).
BrowserModule
仅应在AppModule
中导入,CommonModule
可以在任何地方导入.
BrowserModule
should only be imported in AppModule
, CommonModule
can be imported everywhere.
这篇关于BrowserModule和platformBrowserDynamic有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!