Why Angular export empty class in app.modules.ts?

前端 未结 1 547
猫巷女王i
猫巷女王i 2021-01-12 13:31

I am new in Angular, I am using Angular 4, and I made an app using the Angular CLI, by ng new command.

In main.ts, we have

 ...
import          


        
1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-12 14:11

    The body of the class is indeed empty. But that decorator above the class (@NgModule) is giving that class its functionality. So really, that class isn't empty. It just doesn't require any extra logic after the decorator is applied to it. bootstrapModule takes a class as input and assumes that that class is decorated with @NgModule configured in a manner similar to what you have (declarations, imports, providers, etc.).

    0 讨论(0)
提交回复
热议问题