CommonModule vs BrowserModule的角度 [英] CommonModule vs BrowserModule in angular
问题描述
我对Angular的世界很陌生. CommonModule
与BrowserModule
有什么区别,为什么一个应该比另一个更受青睐?
I am pretty new to the world of Angular. What is the difference between CommonModule
vs BrowserModule
and why one should be preferred over the other?
推荐答案
来自文档
BrowserModule提供了启动和运行操作系统所需的服务. 浏览器应用程序.
BrowserModule provides services that are essential to launch and run a browser app.
BrowserModule还从@ angular/common重新导出CommonModule, 表示AppModule模块中的组件也可以访问 每个应用程序都需要的Angular指令,例如NgIf和NgFor.
BrowserModule also re-exports CommonModule from @angular/common, which means that components in the AppModule module also have access to the Angular directives every app needs, such as NgIf and NgFor.
而
CommonModule (Angular模板的所有基础知识:绑定,* ngIf,* ngFor…),但在第一个应用程序模块中除外,因为它已经属于BrowserModule
CommonModule (all the basics of Angular templating: bindings, *ngIf, *ngFor…), except in the first app module, because it’s already part of the BrowserModule
也请阅读 此 .
Also read this.
这篇关于CommonModule vs BrowserModule的角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!