What is a component?
A component is basically a class that is defined for each element or control visible on the screen. Each component class has some properties, and we can use them to manipulate the behavior or appearance of the element on the screen. In this way, we can create, update or destroy our components depending on the requirements at each stage of the application. But in typing, the component is basically a typing class that has a @Component decorator. An HTML component is a custom user-defined HTML tag that can be rendered in the browser to display any UI element with some sort of business logic.
import { Component } from '@angular/core';?
??
@Component({??
? selector: 'app-root',??
? templateUrl: './app.component.html',??
? styleUrls: ['./app.component.css']??
})??
export class AppComponent {??
? title = 'Welcome to Angular...';??
}?
Decorators are mostly JavaScript functions that make programming simple. The component is a complete, independent block that makes the required logic, layout, and data a single unit. As a developer, to create a component, you just need to pass some configuration objects related to the decorator function to it as an argument or parameter. Logically, each Angular component acts as an MVC concept. Because each component class is an independent unit, it has high reusability and can be stored in other components without any problems.