Angular Component
Angular Component
Contents
• What is Component?
• Creating a new component
• Nesting component
• Component Lifecycles
What is Component?
• Component is the main building block of Angular App
• It has for elements
• HTML - defines what renders on page
• Typescript - a class that defines the behaviour
• Selector - defines how component is used
• CSS - defines the applied styles
Creating new component
To create new component:
details.component.html
<app-service></app-service>
services.component.html
Component Lifecycle
• Angular components are at the heart of Angular applications, and they have a
lifecycle with various hooks that allow you to execute code at specific points during
a component's life.
• Understanding these lifecycle hooks is crucial for managing component behavior
and interactions.
Component Lifecycle
Component Lifecycle
?