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

查看:42
本文介绍了角度中的 CommonModule 与 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 与 BrowserModule的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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