CommonModule vs BrowserModule in angular

前端 未结 4 937
鱼传尺愫
鱼传尺愫 2020-12-15 05:04

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 othe

4条回答
  •  时光取名叫无心
    2020-12-15 05:13

    From the docs

    BrowserModule provides services that are essential to launch and run a browser app.

    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.

    whereas

    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.

提交回复
热议问题