CommonModule vs BrowserModule的角度 [英] CommonModule vs BrowserModule in angular

查看:213
本文介绍了CommonModule vs BrowserModule的角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Angular的世界很陌生. CommonModuleBrowserModule有什么区别,为什么一个应该比另一个更受青睐?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆