SlideShare une entreprise Scribd logo
1  sur  28
Angular 6
Form
Validations BY
SACHINI & MALIKA
SACHINI CHARTHURIKA
Software Engineer @ Ascentic
https://www.linkedin.com/in/sachinichathurika/
MALIKA MUNAWEERA
Software Engineer @ Ascentic
https://www.linkedin.com/in/malikamunaweera/
Agenda
1. Angular 6 Overview.
2. Angular 6 form validation.
 Template driven method.
 Reactive forms method.
3. Add Angular Material to reactive forms
with validations.
4. Advantages and disadvantages
Angular 6 Overview
Released on 4th of May, 2018. Mainly Highlighted new features in
Angular 6:
Angular Command Line Interface (CLI)
The Component Development KIT (CDK)
Angular Material package
Angular Elements
1. Angular 6 fully supports to the Element Package.
2. Allow to use Angular components outside of Angular
like in JQuery or VueJS apps.
3. Can create Angular components and publish them as
Web Components, which can then be used in any
HTML page.
Component Dev Kit (CDK)
1. Released in December of 2017.
2. Can now build your own library of UI components
without using the Angular Material library.
3. Supports Responsive Web Design layouts.
4. CDK includes the @angular/cdk/overlay package.
Command Line Interface (CLI)
Equipped with new commands such as,
ng-update - updates dependencies and code.
ng-add - quickly add application features and supports
to turn applications into progressive web apps.
Allows developers to choose the ng-package for
transpiling different libraries using the Bazel tool.
Other Features
Web Pack Update.
Web pack module bundler has been updated to version4.
Ivy: New Rendering Engine
Expects to increase the speed and decreases the size of the
application.
RxJS 6.0Angular 6 now used RxJS 6 internally.
Provide an increase in performance, easier to debug AJAX call
stacks and improve modularity as backward compatible as
possible.
Earlier
Now
Other Features
Tree Shaking
Angular 6 moved from modules referencing services to
services referencing modules to make the Angular app smaller.
Multiple Validators For Your Forms
Angular 6 now allows you to pass multiple
validators to the formBuilder.
No <template> element and now it’s <ng-
tempalate>.
Best Practices!
Prerequisites
Install Angular CLI 6.
◦NodeJs
◦Npm
◦Beginner level knowledge on
Angular 2/4/5 and HTML.
Template – Driven Form Validation(Demo)
Important Angular CLI
Commands
Create a new project.
ng new validation –routing
Create a new folder and include the required files.
ng g c form-template --spec false
ng g c form-reactive --spec false
Create the compare-validator directive in a shared folder.
ng g d shared/compare-validator --spec false
Run the application locally.
ng serve
Template – Driven Form Validation(Demo)
Different form states that can be used to validate a form:
$untouched - The field has not been touched yet
$touched - The field has been touched
$pristine - The field has not been modified yet
$dirty - The field has been modified
$invalid - The field content is not valid
$valid - The field content is valid
Template – Driven
Form
Validation(Demo)
1. Create a new folder and include the required files.
ng g c form-template --spec false
2. Import BootstrapCDN in styles.css
@import
url(https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/
bootstrap.min.css);
3. Create the compare-validator directive.
ng g d shared/compare-validator --spec false
4. Import forms module to your app module.
import { FormsModule } from '@angular/forms’;
5. HTML page implementation.
6. Configure the app-routings.
Reactive Form Validation (Demo)
Reactive Form
Validation
(Demo)
1. Create a new folder and include the required
files.
ng g c form-reactive --spec false
2. Import the ReactiveFormsModule to the app
module.
3. Create the Reactive form.
4. Change the template driven form to the
reactive form. <form
[formGroup]="reactiveForm">
5. Modify the validation directive.
6. Apply best practices!
Adding Agular Material
& FORM VALIDATIONS WITH MATERIAL
Angular Material
UI component library
Help constructing
◦ attractive,
◦ consistent
◦ functional web pages and web applications
Supports modern web design principles like browser
portability, device independence
Create faster, beautiful, and responsive websites.
Inspired by the Google Material Design.
What’s new with Angular Material
ANGULAR MATERIAL V6
WAS RELEASED ALONG
SIDE ANGULAR 6.
GOING FORWARD MAJOR
RELEASES WILL BE
ALIGNED WITH ANGULAR.
CDK IS NOW A SEPARATE
LIBRARY
ANGULAR MATERIAL
SCHEMATICS
Add Material to
an existing
project (Demo)
Install Angular Material using CDK
◦ This will help you quickly add Material to
a project
◦ Ensure project dependencies in
package.json
◦ Ensure project dependencies in your app
module
◦ Adds Prebuilt or Setup Custom Theme
◦ Adds Roboto fonts to your index.html
◦ Apply simple CSS reset to body
Using starter components
Implementing form validations
With Material (Demo)
Placeholders
Hints
Required fields
Error Messages
Validators
Final Output
Pros & Cons
PROS
With Angular Material you get pre-built
components
Seamless updates using Angular CLI
Powerful ecosystem
CONS
Steep learning curve
Documentation is lacking details
References
 http://jasonwatmore.com/post/2018/05/11/angular-6-template-driven-forms-
validation-example
 http://jasonwatmore.com/post/2018/05/10/angular-6-reactive-forms-
validation-example
 https://material.angular.io
 https://codingthesmartway.com/angular-material-and-angular-6-material-
design-for-angular/
Find the Code
Repository location of Angular 6 form validations
https://github.com/SacheeCG/DevForumAngular6FormVali
dation
Repository location of Angular 6 form validations with
Angular Material.
https://github.com/SacheeCG/DevForumANgular6FormVali
dationwithAngularMaterial
Thank you!

Contenu connexe

Tendances

Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming WebStackAcademy
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency InjectionNir Kaufman
 
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
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.jsTechMagic
 
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!
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event HandlingWebStackAcademy
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJSHoang Long
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data BindingDuy Khanh
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - IntroductionWebStackAcademy
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of SignalsCoding Academy
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced RoutingLaurent Duveau
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - DirectivesWebStackAcademy
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.jsEmanuele DelBono
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners Varun Raj
 

Tendances (20)

Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency Injection
 
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 overview
Angular overviewAngular overview
Angular overview
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
 
Angular
AngularAngular
Angular
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 
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...
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Angular
AngularAngular
Angular
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
 
Vue.js for beginners
Vue.js for beginnersVue.js for beginners
Vue.js for beginners
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 

Similaire à Angular 6 Form Validation with Material

Angular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad indiaAngular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad indiaphp2ranjan
 
Single Page Applications in SharePoint with Angular
Single Page Applications in SharePoint with AngularSingle Page Applications in SharePoint with Angular
Single Page Applications in SharePoint with AngularSparkhound Inc.
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework Yakov Fain
 
Angular js getting started
Angular js getting startedAngular js getting started
Angular js getting startedHemant Mali
 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular applicationSuresh Patidar
 
What’s new in angular 13 and why should you use it for web app development pr...
What’s new in angular 13 and why should you use it for web app development pr...What’s new in angular 13 and why should you use it for web app development pr...
What’s new in angular 13 and why should you use it for web app development pr...Moon Technolabs Pvt. Ltd.
 
Angular Project Report
 Angular Project Report Angular Project Report
Angular Project ReportKodexhub
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesMohamad Al Asmar
 
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.
 
Angular 6 - The Complete Guide
Angular 6 - The Complete GuideAngular 6 - The Complete Guide
Angular 6 - The Complete GuideSam Dias
 
GDG Atlanta - Angular.js Demo and Workshop
GDG Atlanta - Angular.js Demo and WorkshopGDG Atlanta - Angular.js Demo and Workshop
GDG Atlanta - Angular.js Demo and WorkshopDrew Morris
 

Similaire à Angular 6 Form Validation with Material (20)

Angular 2.0
Angular  2.0Angular  2.0
Angular 2.0
 
Angular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad indiaAngular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad india
 
What are The Top Features of Angular 7?
What are The Top Features of Angular 7?What are The Top Features of Angular 7?
What are The Top Features of Angular 7?
 
Single Page Applications in SharePoint with Angular
Single Page Applications in SharePoint with AngularSingle Page Applications in SharePoint with Angular
Single Page Applications in SharePoint with Angular
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
Angular js getting started
Angular js getting startedAngular js getting started
Angular js getting started
 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular application
 
What’s new in angular 13 and why should you use it for web app development pr...
What’s new in angular 13 and why should you use it for web app development pr...What’s new in angular 13 and why should you use it for web app development pr...
What’s new in angular 13 and why should you use it for web app development pr...
 
Angular Project Report
 Angular Project Report Angular Project Report
Angular Project Report
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key Features
 
AngularJS
AngularJSAngularJS
AngularJS
 
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
 
Angular 6 - The Complete Guide
Angular 6 - The Complete GuideAngular 6 - The Complete Guide
Angular 6 - The Complete Guide
 
Angular
AngularAngular
Angular
 
angular
angularangular
angular
 
angular content
angular contentangular content
angular content
 
angular
angularangular
angular
 
angular
angularangular
angular
 
GDG Atlanta - Angular.js Demo and Workshop
GDG Atlanta - Angular.js Demo and WorkshopGDG Atlanta - Angular.js Demo and Workshop
GDG Atlanta - Angular.js Demo and Workshop
 
Why choose Angular 6?
Why choose Angular 6?Why choose Angular 6?
Why choose Angular 6?
 

Dernier

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Dernier (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Angular 6 Form Validation with Material

  • 2. SACHINI CHARTHURIKA Software Engineer @ Ascentic https://www.linkedin.com/in/sachinichathurika/ MALIKA MUNAWEERA Software Engineer @ Ascentic https://www.linkedin.com/in/malikamunaweera/
  • 3. Agenda 1. Angular 6 Overview. 2. Angular 6 form validation.  Template driven method.  Reactive forms method. 3. Add Angular Material to reactive forms with validations. 4. Advantages and disadvantages
  • 4. Angular 6 Overview Released on 4th of May, 2018. Mainly Highlighted new features in Angular 6: Angular Command Line Interface (CLI) The Component Development KIT (CDK) Angular Material package
  • 5. Angular Elements 1. Angular 6 fully supports to the Element Package. 2. Allow to use Angular components outside of Angular like in JQuery or VueJS apps. 3. Can create Angular components and publish them as Web Components, which can then be used in any HTML page.
  • 6. Component Dev Kit (CDK) 1. Released in December of 2017. 2. Can now build your own library of UI components without using the Angular Material library. 3. Supports Responsive Web Design layouts. 4. CDK includes the @angular/cdk/overlay package.
  • 7. Command Line Interface (CLI) Equipped with new commands such as, ng-update - updates dependencies and code. ng-add - quickly add application features and supports to turn applications into progressive web apps. Allows developers to choose the ng-package for transpiling different libraries using the Bazel tool.
  • 8. Other Features Web Pack Update. Web pack module bundler has been updated to version4. Ivy: New Rendering Engine Expects to increase the speed and decreases the size of the application. RxJS 6.0Angular 6 now used RxJS 6 internally. Provide an increase in performance, easier to debug AJAX call stacks and improve modularity as backward compatible as possible.
  • 9. Earlier Now Other Features Tree Shaking Angular 6 moved from modules referencing services to services referencing modules to make the Angular app smaller.
  • 10. Multiple Validators For Your Forms Angular 6 now allows you to pass multiple validators to the formBuilder. No <template> element and now it’s <ng- tempalate>. Best Practices!
  • 11. Prerequisites Install Angular CLI 6. ◦NodeJs ◦Npm ◦Beginner level knowledge on Angular 2/4/5 and HTML.
  • 12. Template – Driven Form Validation(Demo)
  • 13. Important Angular CLI Commands Create a new project. ng new validation –routing Create a new folder and include the required files. ng g c form-template --spec false ng g c form-reactive --spec false Create the compare-validator directive in a shared folder. ng g d shared/compare-validator --spec false Run the application locally. ng serve
  • 14. Template – Driven Form Validation(Demo) Different form states that can be used to validate a form: $untouched - The field has not been touched yet $touched - The field has been touched $pristine - The field has not been modified yet $dirty - The field has been modified $invalid - The field content is not valid $valid - The field content is valid
  • 15. Template – Driven Form Validation(Demo) 1. Create a new folder and include the required files. ng g c form-template --spec false 2. Import BootstrapCDN in styles.css @import url(https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/ bootstrap.min.css); 3. Create the compare-validator directive. ng g d shared/compare-validator --spec false 4. Import forms module to your app module. import { FormsModule } from '@angular/forms’; 5. HTML page implementation. 6. Configure the app-routings.
  • 17. Reactive Form Validation (Demo) 1. Create a new folder and include the required files. ng g c form-reactive --spec false 2. Import the ReactiveFormsModule to the app module. 3. Create the Reactive form. 4. Change the template driven form to the reactive form. <form [formGroup]="reactiveForm"> 5. Modify the validation directive. 6. Apply best practices!
  • 18. Adding Agular Material & FORM VALIDATIONS WITH MATERIAL
  • 19. Angular Material UI component library Help constructing ◦ attractive, ◦ consistent ◦ functional web pages and web applications Supports modern web design principles like browser portability, device independence Create faster, beautiful, and responsive websites. Inspired by the Google Material Design.
  • 20. What’s new with Angular Material ANGULAR MATERIAL V6 WAS RELEASED ALONG SIDE ANGULAR 6. GOING FORWARD MAJOR RELEASES WILL BE ALIGNED WITH ANGULAR. CDK IS NOW A SEPARATE LIBRARY ANGULAR MATERIAL SCHEMATICS
  • 21. Add Material to an existing project (Demo) Install Angular Material using CDK ◦ This will help you quickly add Material to a project ◦ Ensure project dependencies in package.json ◦ Ensure project dependencies in your app module ◦ Adds Prebuilt or Setup Custom Theme ◦ Adds Roboto fonts to your index.html ◦ Apply simple CSS reset to body Using starter components
  • 22. Implementing form validations With Material (Demo) Placeholders Hints Required fields Error Messages Validators
  • 25. PROS With Angular Material you get pre-built components Seamless updates using Angular CLI Powerful ecosystem CONS Steep learning curve Documentation is lacking details
  • 27. Find the Code Repository location of Angular 6 form validations https://github.com/SacheeCG/DevForumAngular6FormVali dation Repository location of Angular 6 form validations with Angular Material. https://github.com/SacheeCG/DevForumANgular6FormVali dationwithAngularMaterial

Notes de l'éditeur

  1. All three are shipped as part of Angular 6, not separate updates. This version release is more focused on the tooling and support rather than the whole framework.
  2. Turning a component into a custom element gives you an easy path for creating dynamic HTML content for your Angular app, and, using the Angular Elements package, it is even easier to create native custom elements.
  3. 1. The Angular Team has made some really neat improvements to it for the 6th version. 2. So you don't have to use other libraries like Flex Layout or even learn using the CSS Grid. It covers them all. 3. This one has a new positioning logic that makes your pop-ups stay on screen very brilliantly.
  4. Without the Bazel tool, you would have to build and package libraries yourself.
  5. Ivy: This important feature is not completely released in Angular 6 since it is in experimental mode; except the complete version in Angular's next release.
  6. All services of the application as well as those of libraries have always been bundled – regardless of whether they were used or not. Tree shaking is a build optimization step which tries to ensure any unused code does not get used in our final bundle.
  7. The <template> element was depreciated one year ago when Angular 4 was launched.
  8. A public content delivery network. Users of BootstrapCDN can load CSS, JavaScript and images remotely, from its servers
  9. Ivy: This important feature is not completely released in Angular 6 since it is in experimental mode; except the complete version in Angular's next release.