Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between an Angular component and module

I've been watching videos and reading articles but this specific article make me so confused, at the start of the article it says

The applications in Angular follow modular structure. The Angular apps will contain many modules, each dedicated to the single purpose. Typically module is a cohesive group of code which is integrated with the other modules to run your Angular apps.

A module exports some classes, function and values from its code. The Component is a fundamental block of Angular and multiple components will make up your application.

A module can be a library for another module. For instance, the angular2/core library which is a primary Angular library module will be imported by another component.

Are they exchangeable terms? Is a component a module? But not viceversa?

like image 345
Luis Pena Avatar asked Oct 04 '22 07:10

Luis Pena


People also ask

What is the difference between component and module?

Components are put together (synthesis) to build a software. Modules are the result of dividing (analysis) the code. So components are about the high-level design of a software, whereas modules are more about organization on the code level.

What is a module in Angular?

Module in Angular refers to a place where you can group the components, directives, pipes, and services, which are related to the application. In case you are developing a website, the header, footer, left, center and the right section become part of a module. To define module, we can use the NgModule.

Does every component need a module Angular?

Every component in our app needs to be declared inside an Angular module for us to use it. We have also imported BrowserModule. The browser module is actually the ng module for our browser, as per Angular's official documentation.

What is component and module Angular 8?

A module is a collection of components, services, pipes, directives, and so on. A component in Angular is a building block of the application with an associated template view. The angular apps will contain many modules, each dedicated to a single purpose.


1 Answers

Components control views (html). They also communicate with other components and services to bring functionality to your app.

Modules consist of one or more components. They do not control any html. Your modules declare which components can be used by components belonging to other modules, which classes will be injected by the dependency injector and which component gets bootstrapped. Modules allow you to manage your components to bring modularity to your app.

like image 330
Sefa Avatar answered Oct 23 '22 01:10

Sefa