SlideShare a Scribd company logo
1 of 24
Download to read offline
Angular (Session - 2)
Nitin Bhojwani nbhojwani@vmware.com
Saket Singh sakets@vmware.com
Nikhil Gupta guptanikhil@vmware.com
Agenda
• Recap of the last talk
“Angular Workshop – 1 (Getting started with Angular)”
• Angular Component Lifecycle
• Modularizing Angular application – How to do and benefits of it
• Angular Routing – Routing in UI
• Hands On
• Essential Code guidelines from Angular Style Guide
Recap
Recap - Angular
• Angular helps you build modern applications for the web, mobile, or
desktop.
• Reusability
• Components( a small patch of screen) are reusable – build once use
everywhere.
• Develop Across all platforms – Desktop, Mobile and others
• Speed and Performance
• Build features quickly with simple, declarative templates
• https://angular.io/guide/architecture
Recap - Why Angular?
Single Page Application
• SPA is fast as most of the resources(HTML, CSS, JS) are only loaded
once throughout the lifespan of application.
• Data is loaded independently using REST apis
• Routing is handled in UI
• Simplified and streamlined
• More Control in UI – Less server involvement
Recap - Why Angular?
Accelerated DOM update
• Accessing DOM tree is costly
• Any runtime change in the page
requires a DOM update. DOM
update for every change will
slaughter performance.
• Optimize DOM updating process
and accelerate it.
Recap - Typescript
• .ts file extension
• JavaScript is Dynamically typed language
• Problematic in bigger projects
• TS provides static typing helps in development and preventing usual
bugs
• Superset of JavaScript
• Even JavaScript code works on Typescript.
• Object Oriented Programming
Recap - Angular Building Blocks
Component
• A component controls a patch of screen called a view.
• Presentation Logic goes here, can invoke based on user actions
• Define:
@Component({
selector: 'app-hero-list’,
templateUrl: './hero-list.component.html’,
providers: [ HeroService ] })
• Use:
<app-hero-list></app-hero-list>
• https://angular.io/guide/architecture-components
Recap - Angular Building Blocks
Service
• Includes any value, function, or feature that an app needs.
• A service is typically a class with a narrow, well-defined purpose.
• Should do something specific and do it well.
• Backend for view(Component)
• Handles functionality
Recap - Clarity Design System
• Open sourced by VMware
• UX guidelines,
HTML/CSS framework, and
Angular components
• Don’t work on view from scratch
• Reuse components provided by Clarity
• https://clarity.design/
Angular Component Lifecycle
Angular Component Lifecycle
• A component has a lifecycle managed by Angular.
• Creation
• Rendering
• Changes
• Destruction
• Makes it possible to execute code at different lifecycle events.
Lifecycle Hooks
ngOnChanges():
• Called before ngOnInit() and whenever one or more data-bound
input properties change.
• Code to react on input changes goes here.
ngOnInit():
• Called once, after the first ngOnChanges()
• Code to initialize component data, set initial values goes here.
ngAfterContentInit():
• Called after Angular projects external content into the component's view. (Stuff that
goes inside "ng-content" tags)
• Pieces of HTML that can be passed from parent and projected in a child component.
Lifecycle Hooks
ngAfterViewInit():
• Triggered after the child components have been instantiated.
• Allows for interaction between parent and child components. (ViewChild is assigned a
valued here)
ngOnDestroy():
• Triggered before a component is disposed.
• Should handle closing streams and disposing off everything active.
Example Lifecycle Event Flow
Modularizing Angular Applications
Modules... What? Who?
• Logical separation of a single monolithic codebase into distinct redistributable packages.
• NgModules can contain components, service providers, and other code files.
• It can import functionality that is exported from other NgModules, and export
selected functionality for use by other NgModules.
• It is independent of the rest of the project.
• Angular has its own modularity system called NgModules.
Modularizing Angular Applications
Why Modules?
• Clean code with proper separation of concern. Each module has a set functional
responsibility.
• Easier to work with since it inherently avoids spaghetti.
• Well defined inter module interaction. Module interfaces generally remain unchanged.
• Reusable across multiple projects.
• Allows for lazy loading of code within the app.
• Each module compiles to a different JS file.
• Few parts of code might not be required at all. No reason to fetch it all at once.
• Greatly reduces the time it takes to initially load the app.
Angular Routing (Demo)
Hands On
(Hands On) Refactoring from last hands-on
• https://github.com/tech-talky/wwc-weather
• After the last hands-on, some refactoring is done:
• weather-status – new feature module
• migrate app.component.html and app.component.ts content to another
component in the new module weather-status
• Basic routing
(Hands On) Bring Code Locally
• Clone the repo and start locally
• git clone https://github.com/tech-talky/wwc-weather
• cd wwc-weather
• npm install
• ng serve –port 5000
• Let’s go through the code
(Hands On) What to do next?
• Start with routing and modularizing
• Create another feature module with children routing and main components:
• forecasting – get new component added
• Configure routing:
• https://angular.io/guide/lazy-loading-ngmodules#routes-at-the-app-level
(Hands On) What to do next?
• Vertical Nav from Clarity
• https://clarity.design/documentation/vertical-nav/collapsible-nav/normal
• forecast.component.ts – main component of forecast module
• Add map component to forecast component
• https://angular-maps.com/guides/getting-started/
• Input to component – lat, long
• Output from component – any new marker on the map
• https://stackblitz.com/edit/angular-google-maps-demo
• Next – Based upon the output from above component get forecasting
Essential Coding Practices
- Separation of Concerns:
• Split into modules - Lazy load your modules depending on need.
• Rule of one – easy reading and maintenance, avoid dependency collisions
- Use services for reusable business logic
• Write small, pure functions
- Make reusable components
- Follow the style guide by Angular (https://angular.io/guide/styleguide)

More Related Content

What's hot

Developing Cross-Platform Web Apps with ASP.NET Core1.0
Developing Cross-Platform Web Apps with ASP.NET Core1.0Developing Cross-Platform Web Apps with ASP.NET Core1.0
Developing Cross-Platform Web Apps with ASP.NET Core1.0EastBanc Tachnologies
 
Continuous delivery of danbury.io, Part 1
Continuous delivery of danbury.io, Part 1Continuous delivery of danbury.io, Part 1
Continuous delivery of danbury.io, Part 1Brian Jackson
 
ECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHERE
ECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHEREECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHERE
ECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHEREEuropean Collaboration Summit
 
Motion design in FIori
Motion design in FIoriMotion design in FIori
Motion design in FIoriRoman Rommel
 
Azure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsaAzure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsaBaskar rao Dsn
 
Алексей Волков "Введение в React Native"
Алексей Волков "Введение в React Native"Алексей Волков "Введение в React Native"
Алексей Волков "Введение в React Native"Fwdays
 
White Paper : ASP.NET Core AngularJs 2 and Prime
White Paper : ASP.NET Core AngularJs 2 and PrimeWhite Paper : ASP.NET Core AngularJs 2 and Prime
White Paper : ASP.NET Core AngularJs 2 and PrimeHamida Rebai Trabelsi
 
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)Movel
 
Building Massive AngularJS Apps
Building Massive AngularJS AppsBuilding Massive AngularJS Apps
Building Massive AngularJS AppsGordon Bockus
 
Using and extending Alfresco Content Application
Using and extending Alfresco Content ApplicationUsing and extending Alfresco Content Application
Using and extending Alfresco Content ApplicationDenys Vuika
 
Creating a Comprehensive Social Media App Using Ionic and Phone Gap
Creating a Comprehensive Social Media App Using Ionic and Phone GapCreating a Comprehensive Social Media App Using Ionic and Phone Gap
Creating a Comprehensive Social Media App Using Ionic and Phone GapFITC
 
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Edureka!
 
Skinny Framework 1.0.0
Skinny Framework 1.0.0Skinny Framework 1.0.0
Skinny Framework 1.0.0Kazuhiro Sera
 
Get Started with ASP.NET Core Training, Tutorial - Beginner to Advance
Get Started with ASP.NET Core Training, Tutorial - Beginner to AdvanceGet Started with ASP.NET Core Training, Tutorial - Beginner to Advance
Get Started with ASP.NET Core Training, Tutorial - Beginner to AdvanceShailendra Chauhan
 
Angular js training in noida
Angular js training in noidaAngular js training in noida
Angular js training in noidanihalsingh113
 

What's hot (20)

Developing Cross-Platform Web Apps with ASP.NET Core1.0
Developing Cross-Platform Web Apps with ASP.NET Core1.0Developing Cross-Platform Web Apps with ASP.NET Core1.0
Developing Cross-Platform Web Apps with ASP.NET Core1.0
 
Continuous delivery of danbury.io, Part 1
Continuous delivery of danbury.io, Part 1Continuous delivery of danbury.io, Part 1
Continuous delivery of danbury.io, Part 1
 
Building iOS app using meteor
Building iOS app using meteorBuilding iOS app using meteor
Building iOS app using meteor
 
ECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHERE
ECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHEREECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHERE
ECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHERE
 
Building mobile apps using meteorJS
Building mobile apps using meteorJSBuilding mobile apps using meteorJS
Building mobile apps using meteorJS
 
Motion design in FIori
Motion design in FIoriMotion design in FIori
Motion design in FIori
 
ATD9 2013 One ASP.NET
ATD9 2013 One ASP.NETATD9 2013 One ASP.NET
ATD9 2013 One ASP.NET
 
Azure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsaAzure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsa
 
Алексей Волков "Введение в React Native"
Алексей Волков "Введение в React Native"Алексей Волков "Введение в React Native"
Алексей Волков "Введение в React Native"
 
Angular universal
Angular universalAngular universal
Angular universal
 
White Paper : ASP.NET Core AngularJs 2 and Prime
White Paper : ASP.NET Core AngularJs 2 and PrimeWhite Paper : ASP.NET Core AngularJs 2 and Prime
White Paper : ASP.NET Core AngularJs 2 and Prime
 
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
 
Building Massive AngularJS Apps
Building Massive AngularJS AppsBuilding Massive AngularJS Apps
Building Massive AngularJS Apps
 
Using and extending Alfresco Content Application
Using and extending Alfresco Content ApplicationUsing and extending Alfresco Content Application
Using and extending Alfresco Content Application
 
Creating a Comprehensive Social Media App Using Ionic and Phone Gap
Creating a Comprehensive Social Media App Using Ionic and Phone GapCreating a Comprehensive Social Media App Using Ionic and Phone Gap
Creating a Comprehensive Social Media App Using Ionic and Phone Gap
 
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
 
ASP.NET 5 Overview
ASP.NET 5 OverviewASP.NET 5 Overview
ASP.NET 5 Overview
 
Skinny Framework 1.0.0
Skinny Framework 1.0.0Skinny Framework 1.0.0
Skinny Framework 1.0.0
 
Get Started with ASP.NET Core Training, Tutorial - Beginner to Advance
Get Started with ASP.NET Core Training, Tutorial - Beginner to AdvanceGet Started with ASP.NET Core Training, Tutorial - Beginner to Advance
Get Started with ASP.NET Core Training, Tutorial - Beginner to Advance
 
Angular js training in noida
Angular js training in noidaAngular js training in noida
Angular js training in noida
 

Similar to Angular meetup 2 2019-08-29

Building Blocks of Angular 2 and ASP.NET Core
Building Blocks of Angular 2 and ASP.NET CoreBuilding Blocks of Angular 2 and ASP.NET Core
Building Blocks of Angular 2 and ASP.NET CoreLevi Fuller
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectJadson Santos
 
Angular.ppt
Angular.pptAngular.ppt
Angular.pptMytrux1
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - IntroductionSenthil Kumar
 
Introduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setupIntroduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setupAnsley Rodrigues
 
Foster - Getting started with Angular
Foster - Getting started with AngularFoster - Getting started with Angular
Foster - Getting started with AngularMukundSonaiya1
 
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]Alex Ershov
 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day WorkshopShyam Seshadri
 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) PresentationRaghubir Singh
 
Evolution and History of Angular as Web Development Platform.pdf
Evolution and History of Angular as Web Development Platform.pdfEvolution and History of Angular as Web Development Platform.pdf
Evolution and History of Angular as Web Development Platform.pdfiFour Technolab Pvt. Ltd.
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework Yakov Fain
 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular applicationSuresh Patidar
 

Similar to Angular meetup 2 2019-08-29 (20)

Angular 2.0
Angular  2.0Angular  2.0
Angular 2.0
 
Angular 14.pptx
Angular 14.pptxAngular 14.pptx
Angular 14.pptx
 
Building Blocks of Angular 2 and ASP.NET Core
Building Blocks of Angular 2 and ASP.NET CoreBuilding Blocks of Angular 2 and ASP.NET Core
Building Blocks of Angular 2 and ASP.NET Core
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
Angular 2
Angular 2Angular 2
Angular 2
 
Angular IO
Angular IOAngular IO
Angular IO
 
Angular.ppt
Angular.pptAngular.ppt
Angular.ppt
 
Angular vs react
Angular vs reactAngular vs react
Angular vs react
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - Introduction
 
Angular 9
Angular 9 Angular 9
Angular 9
 
Introduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setupIntroduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setup
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
Foster - Getting started with Angular
Foster - Getting started with AngularFoster - Getting started with Angular
Foster - Getting started with Angular
 
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day Workshop
 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) Presentation
 
Evolution and History of Angular as Web Development Platform.pdf
Evolution and History of Angular as Web Development Platform.pdfEvolution and History of Angular as Web Development Platform.pdf
Evolution and History of Angular as Web Development Platform.pdf
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
Angular
AngularAngular
Angular
 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular application
 

Recently uploaded

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 

Recently uploaded (20)

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 

Angular meetup 2 2019-08-29

  • 1. Angular (Session - 2) Nitin Bhojwani nbhojwani@vmware.com Saket Singh sakets@vmware.com Nikhil Gupta guptanikhil@vmware.com
  • 2. Agenda • Recap of the last talk “Angular Workshop – 1 (Getting started with Angular)” • Angular Component Lifecycle • Modularizing Angular application – How to do and benefits of it • Angular Routing – Routing in UI • Hands On • Essential Code guidelines from Angular Style Guide
  • 4. Recap - Angular • Angular helps you build modern applications for the web, mobile, or desktop. • Reusability • Components( a small patch of screen) are reusable – build once use everywhere. • Develop Across all platforms – Desktop, Mobile and others • Speed and Performance • Build features quickly with simple, declarative templates • https://angular.io/guide/architecture
  • 5. Recap - Why Angular? Single Page Application • SPA is fast as most of the resources(HTML, CSS, JS) are only loaded once throughout the lifespan of application. • Data is loaded independently using REST apis • Routing is handled in UI • Simplified and streamlined • More Control in UI – Less server involvement
  • 6. Recap - Why Angular? Accelerated DOM update • Accessing DOM tree is costly • Any runtime change in the page requires a DOM update. DOM update for every change will slaughter performance. • Optimize DOM updating process and accelerate it.
  • 7. Recap - Typescript • .ts file extension • JavaScript is Dynamically typed language • Problematic in bigger projects • TS provides static typing helps in development and preventing usual bugs • Superset of JavaScript • Even JavaScript code works on Typescript. • Object Oriented Programming
  • 8. Recap - Angular Building Blocks Component • A component controls a patch of screen called a view. • Presentation Logic goes here, can invoke based on user actions • Define: @Component({ selector: 'app-hero-list’, templateUrl: './hero-list.component.html’, providers: [ HeroService ] }) • Use: <app-hero-list></app-hero-list> • https://angular.io/guide/architecture-components
  • 9. Recap - Angular Building Blocks Service • Includes any value, function, or feature that an app needs. • A service is typically a class with a narrow, well-defined purpose. • Should do something specific and do it well. • Backend for view(Component) • Handles functionality
  • 10. Recap - Clarity Design System • Open sourced by VMware • UX guidelines, HTML/CSS framework, and Angular components • Don’t work on view from scratch • Reuse components provided by Clarity • https://clarity.design/
  • 12. Angular Component Lifecycle • A component has a lifecycle managed by Angular. • Creation • Rendering • Changes • Destruction • Makes it possible to execute code at different lifecycle events.
  • 13. Lifecycle Hooks ngOnChanges(): • Called before ngOnInit() and whenever one or more data-bound input properties change. • Code to react on input changes goes here. ngOnInit(): • Called once, after the first ngOnChanges() • Code to initialize component data, set initial values goes here. ngAfterContentInit(): • Called after Angular projects external content into the component's view. (Stuff that goes inside "ng-content" tags) • Pieces of HTML that can be passed from parent and projected in a child component.
  • 14. Lifecycle Hooks ngAfterViewInit(): • Triggered after the child components have been instantiated. • Allows for interaction between parent and child components. (ViewChild is assigned a valued here) ngOnDestroy(): • Triggered before a component is disposed. • Should handle closing streams and disposing off everything active.
  • 16. Modularizing Angular Applications Modules... What? Who? • Logical separation of a single monolithic codebase into distinct redistributable packages. • NgModules can contain components, service providers, and other code files. • It can import functionality that is exported from other NgModules, and export selected functionality for use by other NgModules. • It is independent of the rest of the project. • Angular has its own modularity system called NgModules.
  • 17. Modularizing Angular Applications Why Modules? • Clean code with proper separation of concern. Each module has a set functional responsibility. • Easier to work with since it inherently avoids spaghetti. • Well defined inter module interaction. Module interfaces generally remain unchanged. • Reusable across multiple projects. • Allows for lazy loading of code within the app. • Each module compiles to a different JS file. • Few parts of code might not be required at all. No reason to fetch it all at once. • Greatly reduces the time it takes to initially load the app.
  • 20. (Hands On) Refactoring from last hands-on • https://github.com/tech-talky/wwc-weather • After the last hands-on, some refactoring is done: • weather-status – new feature module • migrate app.component.html and app.component.ts content to another component in the new module weather-status • Basic routing
  • 21. (Hands On) Bring Code Locally • Clone the repo and start locally • git clone https://github.com/tech-talky/wwc-weather • cd wwc-weather • npm install • ng serve –port 5000 • Let’s go through the code
  • 22. (Hands On) What to do next? • Start with routing and modularizing • Create another feature module with children routing and main components: • forecasting – get new component added • Configure routing: • https://angular.io/guide/lazy-loading-ngmodules#routes-at-the-app-level
  • 23. (Hands On) What to do next? • Vertical Nav from Clarity • https://clarity.design/documentation/vertical-nav/collapsible-nav/normal • forecast.component.ts – main component of forecast module • Add map component to forecast component • https://angular-maps.com/guides/getting-started/ • Input to component – lat, long • Output from component – any new marker on the map • https://stackblitz.com/edit/angular-google-maps-demo • Next – Based upon the output from above component get forecasting
  • 24. Essential Coding Practices - Separation of Concerns: • Split into modules - Lazy load your modules depending on need. • Rule of one – easy reading and maintenance, avoid dependency collisions - Use services for reusable business logic • Write small, pure functions - Make reusable components - Follow the style guide by Angular (https://angular.io/guide/styleguide)