Angular2: Module and Component difference

后端 未结 2 1447
天命终不由人
天命终不由人 2021-01-07 18:48

I don\'t quite to figure out, why Angular2 have two concepts?

  1. Module

  2. Component

What is the difference between them and w

2条回答
  •  猫巷女王i
    2021-01-07 19:33

    Module and Component have hardly anything in common, except that they are classes with decorators and providers can registered with them.

    A component is a visible part of your application with optional behavior (event handlers)

    Modules were introduced to split your application for lazy loading.

    • SubModule is usually a set of services, components, directives, and pipes that build together a reusable feature. By adding a module to imports: [...] of another module, all its content is made available to the importing module.

    • SubComponent is not really a term in Angular2. There are just components. One special component is the root component. The difference is that the root component is created by bootstrapping an Angular2 application, while other components are created because their selector matches HTML in the view of another component.

    Therefor, except of the root component all components are subcomponents.

提交回复
热议问题