SlideShare a Scribd company logo
Angular : Lifecycle Hooks
Byteridge
Introduction
● Firstly, we won’t be reading this blog if there is no Angular…,, So, Lifecycle
hooks have been part of Angular since version 2 (it’s long right <3). Lifecycle
hooks have been loyal to Angular for nearly 5 years and promises to be for
life. Enough of this coming to Actual stuff.
● Directive and Component instances have a lifecycle as Angular creates,
updates, and destroys them. Developers can tap into critical moments in that
lifecycle by implementing one or more of the lifecycle hook interfaces in the
Angular core library. Each interface has a single hook method whose name is
the interface name prefixed with ng.
● When an Angular project is initialized, Angular creates and presents its root
components. It is designed and it produces its heirs. For the components that
are loaded during application development, Angular keeps checking when
data binding properties are changed and updated.
Byteridge
When are Lifecycle hooks called?
● A component in Angular has a lifecycle, a number of different phases it goes
through from birth to death.
● It is interesting to notice that Angular itself oversees all the lifecycle of Angular
Components and Directives, you have to understand the lifecycle with the result
in mind to have the smooth progress of your application. The following
information that I will share applies to both Components and Directives.
● Components are the primary building block for any Angular application.
● So it becomes utmost important to understand them to understand the
processing steps of the lifecycle of components, then only it can be implemented
in the application development using Angular.
Byteridge
How many Lifecycle hooks exist?
Constructor:
● This is invoked when Angular creates a component or directive by calling new on
the class.,
● The constructor method is not actually an Angular 2 method. It is a predefined
method in a TypeScript class which is called when the class is instantiated.
ngOnChanges:
● Invoked every time there is a change in one of the input properties of the
component.
● The ngOnChanges() method is a lifecycle hook that will trigger each time Angular
sets a data-bound input property. That means that it should be used whenever we
need something to happen whenever that property value changes.
Byteridge
CTPN
ngOnInit
● Invoked when given component has been initialized. This hook is only called
once after the ngOnChanges.
● The ngOnInit method runs after the constructor method, meaning that all of the
injected dependencies will be resolved and all of the class members will be
defined.
ngDoCheck
● Invoked when the change detector of the given component is invoked. This
hook detects and acts upon every change that Angular can’t find automatically.
It gets called before ngOnChanges() and ngOnInit() methods.
Byteridge
Contact: +91 40491 74522
Mail : info@byteridge.com
Address: WeWork Rajapushpa Summit, Financial District, Hyderabad, Telangana
Visit here for more : https://www.byteridge.com/expert-opinions/angular-lifecycle-hooks/
Byteridge
CONTACT US

More Related Content

PPTX
Angular Lifecycle Hooks
PPTX
yrs of IT experience in enterprise programming
PPTX
Angular crash course
PPTX
Angular js 1.0-fundamentals
PDF
Angular meetup 2 2019-08-29
PPTX
Angular 2 in-1
PPTX
Salesforce lwc development workshops session #6
PPTX
We are providing Angular Training in Mumbai
Angular Lifecycle Hooks
yrs of IT experience in enterprise programming
Angular crash course
Angular js 1.0-fundamentals
Angular meetup 2 2019-08-29
Angular 2 in-1
Salesforce lwc development workshops session #6
We are providing Angular Training in Mumbai

Similar to Angular _ Lifecycle Hooks - Byteridge.pptx (8)

PDF
Angular, the New Angular JS
PPTX
Angularjs Performance
PDF
Infosys Angular Interview Questions PDF By ScholarHat
PPTX
Angular interview questions
PDF
Angular Advanced Workshop (+ Challenges)
PDF
Building Blocks of Angular 2 and ASP.NET Core
PDF
Angular js
PDF
Angular js
Angular, the New Angular JS
Angularjs Performance
Infosys Angular Interview Questions PDF By ScholarHat
Angular interview questions
Angular Advanced Workshop (+ Challenges)
Building Blocks of Angular 2 and ASP.NET Core
Angular js
Angular js
Ad

More from reachbyteridge (8)

PPTX
A Complete Guide to Mobile App Development.pptx
PPTX
Travel 2.0 – A Product Concept.pptx
PPTX
What is “Scope Creep” - Byteridge.pptx
PPTX
White Paper on Effective Risk Management.pptx
PPTX
Working with Cross-Functional Teams.pptx
PPTX
Generative Artificial Intelligence (GEN AI) Models.pptx
PPTX
Mobile Application Development Serv.pptx
PPTX
5 Ways to Lower Technical Debt Through Modernization.pptx
A Complete Guide to Mobile App Development.pptx
Travel 2.0 – A Product Concept.pptx
What is “Scope Creep” - Byteridge.pptx
White Paper on Effective Risk Management.pptx
Working with Cross-Functional Teams.pptx
Generative Artificial Intelligence (GEN AI) Models.pptx
Mobile Application Development Serv.pptx
5 Ways to Lower Technical Debt Through Modernization.pptx
Ad

Recently uploaded (20)

PPTX
A Presentation on Artificial Intelligence
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Approach and Philosophy of On baking technology
PPTX
Cloud computing and distributed systems.
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Big Data Technologies - Introduction.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
A Presentation on Artificial Intelligence
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
“AI and Expert System Decision Support & Business Intelligence Systems”
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Approach and Philosophy of On baking technology
Cloud computing and distributed systems.
Network Security Unit 5.pdf for BCA BBA.
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
The AUB Centre for AI in Media Proposal.docx
Machine learning based COVID-19 study performance prediction
Encapsulation_ Review paper, used for researhc scholars
Big Data Technologies - Introduction.pptx
Encapsulation theory and applications.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
20250228 LYD VKU AI Blended-Learning.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...

Angular _ Lifecycle Hooks - Byteridge.pptx

  • 1. Angular : Lifecycle Hooks Byteridge
  • 2. Introduction ● Firstly, we won’t be reading this blog if there is no Angular…,, So, Lifecycle hooks have been part of Angular since version 2 (it’s long right <3). Lifecycle hooks have been loyal to Angular for nearly 5 years and promises to be for life. Enough of this coming to Actual stuff. ● Directive and Component instances have a lifecycle as Angular creates, updates, and destroys them. Developers can tap into critical moments in that lifecycle by implementing one or more of the lifecycle hook interfaces in the Angular core library. Each interface has a single hook method whose name is the interface name prefixed with ng. ● When an Angular project is initialized, Angular creates and presents its root components. It is designed and it produces its heirs. For the components that are loaded during application development, Angular keeps checking when data binding properties are changed and updated. Byteridge
  • 3. When are Lifecycle hooks called? ● A component in Angular has a lifecycle, a number of different phases it goes through from birth to death. ● It is interesting to notice that Angular itself oversees all the lifecycle of Angular Components and Directives, you have to understand the lifecycle with the result in mind to have the smooth progress of your application. The following information that I will share applies to both Components and Directives. ● Components are the primary building block for any Angular application. ● So it becomes utmost important to understand them to understand the processing steps of the lifecycle of components, then only it can be implemented in the application development using Angular. Byteridge
  • 4. How many Lifecycle hooks exist? Constructor: ● This is invoked when Angular creates a component or directive by calling new on the class., ● The constructor method is not actually an Angular 2 method. It is a predefined method in a TypeScript class which is called when the class is instantiated. ngOnChanges: ● Invoked every time there is a change in one of the input properties of the component. ● The ngOnChanges() method is a lifecycle hook that will trigger each time Angular sets a data-bound input property. That means that it should be used whenever we need something to happen whenever that property value changes. Byteridge
  • 5. CTPN ngOnInit ● Invoked when given component has been initialized. This hook is only called once after the ngOnChanges. ● The ngOnInit method runs after the constructor method, meaning that all of the injected dependencies will be resolved and all of the class members will be defined. ngDoCheck ● Invoked when the change detector of the given component is invoked. This hook detects and acts upon every change that Angular can’t find automatically. It gets called before ngOnChanges() and ngOnInit() methods. Byteridge
  • 6. Contact: +91 40491 74522 Mail : info@byteridge.com Address: WeWork Rajapushpa Summit, Financial District, Hyderabad, Telangana Visit here for more : https://www.byteridge.com/expert-opinions/angular-lifecycle-hooks/ Byteridge CONTACT US