SlideShare uma empresa Scribd logo
1 de 54
Baixar para ler offline
presented by
Paras Mendiratta
1. Introduction
Introduction
“Angular is a Javascript Framework which allows you to create reactive
Single-Page-Applications (SPAs)”
3
Features
Cross Platform
➡ Progressive Web Apps
➡ Native Mobile Apps
➡ Desktop
Speed and Performance
➡ Code Generation
➡ Universal
➡ Code Splitting
4
Features
Productivity
➡ Templates
➡ Angular CLI
➡ IDEs
Full Development Story
➡ Testing
➡ Animation
➡ Accessibility
5
2. Comparison
Comparison
Attribute Angular JS Angular 2 React
DOM Regular DOM Regular DOM Virtual DOM
Packaging Weak Medium Strong
Abstraction Weak Medium Strong
Debugging General Good HTML / Bad JS Goos JS / Good HTML Good JS / Bad HTML
Binding 2 Way 2 Way Uni-Directional
Templating HTML TypeScript JSX
Component Model Weak Strong Medium
MVC YES YES View Layer Only
Rendering Client Side Client Side Server Side
9
3. Tools
NodeJS
http://nodejs.org
11
Angular CLI
https://cli.angular.io/
“Angular CLI is a command line interface for Angular”
12
Visual Studio Code
http://code.visualstudio.com/
“ Visual Studio Code is a source code editor developed by Microsoft for
Windows, Linux and macOS. It includes support for debugging, embedded Git
control, syntax highlighting, intelligent code completion, snippets, and code
refactoring ”
13
4. TypeScript
Introduction to Typescript
“TypeScript is a typed
superset of JavaScript.”
17
TypeScript & ECMAScript
“TypeScript is pure object oriented with classes,
interfaces and statically typed like C# or Java.”
18
Data Types - TypeScript
Data Type Keyword Description
Number number
Double precision 64-bit floating point values. It can be used
to represent both, integers and fractions.
String string Represents a sequence of Unicode characters
Boolean Boolean Represents logical values, true and false
Void void
Used on function return types to represent non-returning
functions
Null null Represents an intentional absence of an object value.
Undefined undefined Denotes value given to all uninitialised variables
19
Null & Undefined
Controversy
✓ null & undefined are not same.
✓ null => The variable has been set to an object whose
value is undefined.
✓ undefined => A variable initialised with undefined
means that the variable has no value or object
assigned to it.
20
Javascript <-> Typescript
✓ Operators => Conditional and Bitwise Operators
✓ Loops => For and While
✓ Decision Making => If else
✓ Arrays
✓ JSON object
What’s common between Javascript and TypeScript?
21
Variables - Typescript
✓ // The variable stores a value of type string

var name:string = “mary”;
✓ // The variable is a string variable. The variable’s value is set to
undefined by default

var name:string;
✓ // The variable’s type is inferred from the data type of the value. Here,
the variable is of the type string

var name = “marry”;
✓ // The variable’s data type is any. Its value is set to undefined by default.

var name;
22
Functions #1 - Typescript
✓ // Function with optional parameter

function disp_details(id:number,name:string,mail_id?:string)
{
console.log("ID:", id);
console.log("Name",name);
if(mail_id!=undefined)
console.log("Email Id",mail_id);
}


disp_details(123,"John");
disp_details(111,"mary","mary@xyz.com");
23
Functions #2 - Typescript
✓ // Function with rest parameter

function addNumbers(…nums:number[ ]) {
var i;
var sum:number = 0;
for (i = 0; i < nums.length; i++) {
sum = sum + nums[ i ];
}
console.log("sum of the numbers”, sum);
}


addNumbers(1, 2, 3);
addNumbers(10, 10, 10, 10, 10);
24
Tuples - Typescript
✓ // Defining a tuple

var myTuple = [ ];
✓ // Defining a tuple and assigning values at same time

var myTuple = [10, 20.3, “Angular JS”];
✓ // Accessing a tuple value

console.log(“Tuple at #2”, myTuple[2]);

console.log(“Tuple at #0”, myTuple[0]);

console.log(“Tuple at #1”, myTuple[1]);
“Tuples are similar to Arrays but can store multiple data type in same
variable”
25
Union - Typescript
✓ // Defining a union

var myUnion:string|number;
✓ // Assigning values to a union variable

myUnion = 10;

myUnion = “This is a string value assigned to Union
variable”;
“Union is the type of variable that can store more
than one data type.”
26
Interfaces - Typescript
✓ // Lets consider an object

var person = {
FirstName:"Tom",
LastName:"Hanks",
sayHi: ()=>{ return "Hi"} 

};
✓ To reuse the signature across objects we can define it as
an interface.
“An interface is a syntactical contract that an entity
should conform to.”
27
Interfaces Example
interface IPerson {
firstName:string,
lastName:string,
sayHi: ()=>string
}
var customer:IPerson = {
firstName:"Tom",
lastName:"Hanks",
sayHi: ():string =>{return "Hi there"}
}
console.log("Customer Object ")
console.log(customer.firstName)
console.log(customer.lastName)
console.log(customer.sayHi())
var employee:IPerson = {
firstName:"Jim",
lastName:"Blakes",
sayHi: ():string =>{return "Hello!!!"}
}
console.log("Employee Object ")
console.log(employee.firstName) console.log(employee.lastName);
28
Classes - Typescript
“A class in terms of OOP is a blueprint for creating
objects. A class encapsulates data for the object.”
class Car {
//field
engine:string;
//constructor
constructor(engine:string) {
this.engine = engine
}
//function
disp():void {
console.log("Engine is : “ + this.engine);
}
}
29
Namespaces - Typescript
“A namespace is a way to logically group related code. It
helps in resolving global namespace pollution problem
presents in Javascript.”
Example:-


namespace SomeNameSpaceName {
export interface ISomeInterfaceName { }
export class SomeClassName { }
}
“The classes or interfaces which should be accessed outside
the namespace should be marked with keyword export.”
30
Modules - Typescript
“A module is designed with the idea to organise
code written in TypeScript.”
Internal External
31
Internal Modules
“Internal modules came in earlier version of
Typescript and now replaced by namespaces.”
32
External Modules
“External modules in TypeScript exists to specify and
load dependencies between multiple external JS files.”
Example:-


import someInterfaceRef = require(“./SomeInterface”);
There are two occasions when we need to load external JS files:-
➡ Server Side - NodeJs
➡ Client Side - RequireJs
33
5. Architecture
Architecture
Components Directives
ServicesRouters
ngModule
35
6. ngModule
ngModule
• Module is a group of components in Angular JS 2.
• We can import one or more module in another module
and all associated will automatically get imported.
• We need not to worry about importing each component
individually.
“NgModules help organise an application into cohesive
blocks of functionality”
Features:
37
ngModule
• Feature as a Module
• Shared Utilities as a Module
How modules should be organised?
There are no standard way to group modules, but the
recommendations are:
https://scotch.io/bar-talk/getting-to-know-angular-2s-module-ngmodule
38
ngModule
@NgModule({
declarations: [ // put all your components / directives / pipes here
AppComponent, // the root component
No1Component, No2Component, ... // e.g. put all 10 components here
AComponent, BComponent, // e.g. put component A and B here
NiceDirective,
AwesomePipe,
],
imports: [ // put all your modules here
BrowserModule, // Angular 2 out of the box modules
TranslateModule, // some third party modules / libraries
],
providers: [ // put all your services here
AwesomeService,
],
bootstrap: [ // The main components to be bootstrapped in main.ts file,
normally one only
AppComponent
]
})
export class AppModule { }
Components
“Encapsulate the template, data and the behaviour
of view. Also known as view components”
40
Directives
“Modifies DOM elements and/or extend their
behaviour”
41
Routes
“Responsible for navigation”
42
Services
“Responsible for arranging data for view
components”
43
7. Components

(a.k.a ViewComponents)
Components
“Encapsulate the template, data and the behaviour of view. Also known as view components”
{ } Root Component
{ } { }
{ } { } { }
45
Navbar
Sidebar Content
{ } { }
{ }
Creating Component
“Component can be creating using Angular CLI tool”
Example:-


ng generate component my-new-component
ng	g	component	my-new-component	#	using	the	alias



#	components	support	relative	path	generation	
#	if	in	the	directory	src/app/feature/	and	you	run	
ng	g	component	new-cmp	
#	your	component	will	be	generated	in	src/app/feature/new-cmp	


#	but	if	you	were	to	run	
ng	g	component	../newer-cmp	
#	your	component	will	be	generated	in	src/app/newer-cmp
49
Signature for Component
50
✓ Selector Name:- Tag name that needs to be
searched in parent template
✓ Template URL:- Path of HTML template file
associated with this component
✓ Style URLs:- String Array containing path of CSS files
that are used to decorate this component.
In component we need to define following details:-
Component Example
import { Component } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'selector-demo',
templateUrl: 'demo.component.html',
styleUrls: ['demo.component.css',

'demo2.component.css']
})
export class DemoComponent { }
51
Wrapping up
✓ Introduction to Angular JS
✓ Difference b/w Angular and Angular 2 and React JS
✓ Development Tools
✓ Basics of TypeScript
✓ Angular JS Architecture
Topics Covered
Next Session
๏ Passing data and events between components
๏ Directives and Pipes
๏ Model Classes
๏ Forms and Validation
52
Thank You

Mais conteúdo relacionado

Mais procurados (20)

Java script
Java scriptJava script
Java script
 
Fundamental JavaScript [In Control 2009]
Fundamental JavaScript [In Control 2009]Fundamental JavaScript [In Control 2009]
Fundamental JavaScript [In Control 2009]
 
Java script tutorial
Java script tutorialJava script tutorial
Java script tutorial
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
 
Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
 
Seaside - Web Development As You Like It
Seaside - Web Development As You Like ItSeaside - Web Development As You Like It
Seaside - Web Development As You Like It
 
Java script
Java scriptJava script
Java script
 
Java script Learn Easy
Java script Learn Easy Java script Learn Easy
Java script Learn Easy
 
Introduction to JavaScript Basics.
Introduction to JavaScript Basics.Introduction to JavaScript Basics.
Introduction to JavaScript Basics.
 
Web 6 | JavaScript DOM
Web 6 | JavaScript DOMWeb 6 | JavaScript DOM
Web 6 | JavaScript DOM
 
Javascript
JavascriptJavascript
Javascript
 
Javascript
JavascriptJavascript
Javascript
 
Javascript
JavascriptJavascript
Javascript
 
WEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScriptWEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScript
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
 
Lab#1 - Front End Development
Lab#1 - Front End DevelopmentLab#1 - Front End Development
Lab#1 - Front End Development
 
Javascript by geetanjali
Javascript by geetanjaliJavascript by geetanjali
Javascript by geetanjali
 
Java script
Java scriptJava script
Java script
 
Javascript tutorial
Javascript tutorialJavascript tutorial
Javascript tutorial
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 

Semelhante a Angular JS2 Training Session #1

HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPTHSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPTAAFREEN SHAIKH
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingHoat Le
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLsintelliyole
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJSWei Ru
 
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)lennartkats
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Domkaven yan
 
Angular 2 Essential Training
Angular 2 Essential Training Angular 2 Essential Training
Angular 2 Essential Training Patrick Schroeder
 
JavaScript lesson 1.pptx
JavaScript lesson 1.pptxJavaScript lesson 1.pptx
JavaScript lesson 1.pptxMuqaddarNiazi1
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsMike Subelsky
 
Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications  Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications Juliana Lucena
 

Semelhante a Angular JS2 Training Session #1 (20)

Wt unit 2 ppts client side technology
Wt unit 2 ppts client side technologyWt unit 2 ppts client side technology
Wt unit 2 ppts client side technology
 
Wt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technologyWt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technology
 
JavaScripts & jQuery
JavaScripts & jQueryJavaScripts & jQuery
JavaScripts & jQuery
 
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPTHSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction Training
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
 
Angular js
Angular jsAngular js
Angular js
 
IOC + Javascript
IOC + JavascriptIOC + Javascript
IOC + Javascript
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
 
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
 
CSC PPT 12.pptx
CSC PPT 12.pptxCSC PPT 12.pptx
CSC PPT 12.pptx
 
Unit 4(it workshop)
Unit 4(it workshop)Unit 4(it workshop)
Unit 4(it workshop)
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
 
Angular 2 Essential Training
Angular 2 Essential Training Angular 2 Essential Training
Angular 2 Essential Training
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 
JavaScript lesson 1.pptx
JavaScript lesson 1.pptxJavaScript lesson 1.pptx
JavaScript lesson 1.pptx
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications  Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications
 

Último

What need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersWhat need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersEmilyJiang23
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems ApproachNeo4j
 
Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...
Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...
Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...Marko Lohert
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Henry Schreiner
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletAndrea Goulet
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Andrea Goulet
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Soroosh Khodami
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabbereGrabber
 
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...OnePlan Solutions
 
SQL Injection Introduction and Prevention
SQL Injection Introduction and PreventionSQL Injection Introduction and Prevention
SQL Injection Introduction and PreventionMohammed Fazuluddin
 
Malaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptxMalaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptxMok TH
 
Jax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckJax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckMarc Lester
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMarkus Moeller
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationWave PLM
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfVictor Lopez
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationElement34
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfMehmet Akar
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfICS
 
Sourcing Success - How to Find a Clothing Manufacturer
Sourcing Success - How to Find a Clothing ManufacturerSourcing Success - How to Find a Clothing Manufacturer
Sourcing Success - How to Find a Clothing ManufacturerWave PLM
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfQ-Advise
 

Último (20)

What need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersWhat need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java Developers
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
 
Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...
Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...
Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea Goulet
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
 
SQL Injection Introduction and Prevention
SQL Injection Introduction and PreventionSQL Injection Introduction and Prevention
SQL Injection Introduction and Prevention
 
Malaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptxMalaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptx
 
Jax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckJax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined Deck
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdf
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test Automation
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
 
Sourcing Success - How to Find a Clothing Manufacturer
Sourcing Success - How to Find a Clothing ManufacturerSourcing Success - How to Find a Clothing Manufacturer
Sourcing Success - How to Find a Clothing Manufacturer
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 

Angular JS2 Training Session #1

  • 3. Introduction “Angular is a Javascript Framework which allows you to create reactive Single-Page-Applications (SPAs)” 3
  • 4. Features Cross Platform ➡ Progressive Web Apps ➡ Native Mobile Apps ➡ Desktop Speed and Performance ➡ Code Generation ➡ Universal ➡ Code Splitting 4
  • 5. Features Productivity ➡ Templates ➡ Angular CLI ➡ IDEs Full Development Story ➡ Testing ➡ Animation ➡ Accessibility 5
  • 7.
  • 8.
  • 9. Comparison Attribute Angular JS Angular 2 React DOM Regular DOM Regular DOM Virtual DOM Packaging Weak Medium Strong Abstraction Weak Medium Strong Debugging General Good HTML / Bad JS Goos JS / Good HTML Good JS / Bad HTML Binding 2 Way 2 Way Uni-Directional Templating HTML TypeScript JSX Component Model Weak Strong Medium MVC YES YES View Layer Only Rendering Client Side Client Side Server Side 9
  • 12. Angular CLI https://cli.angular.io/ “Angular CLI is a command line interface for Angular” 12
  • 13. Visual Studio Code http://code.visualstudio.com/ “ Visual Studio Code is a source code editor developed by Microsoft for Windows, Linux and macOS. It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring ” 13
  • 14.
  • 15.
  • 17. Introduction to Typescript “TypeScript is a typed superset of JavaScript.” 17
  • 18. TypeScript & ECMAScript “TypeScript is pure object oriented with classes, interfaces and statically typed like C# or Java.” 18
  • 19. Data Types - TypeScript Data Type Keyword Description Number number Double precision 64-bit floating point values. It can be used to represent both, integers and fractions. String string Represents a sequence of Unicode characters Boolean Boolean Represents logical values, true and false Void void Used on function return types to represent non-returning functions Null null Represents an intentional absence of an object value. Undefined undefined Denotes value given to all uninitialised variables 19
  • 20. Null & Undefined Controversy ✓ null & undefined are not same. ✓ null => The variable has been set to an object whose value is undefined. ✓ undefined => A variable initialised with undefined means that the variable has no value or object assigned to it. 20
  • 21. Javascript <-> Typescript ✓ Operators => Conditional and Bitwise Operators ✓ Loops => For and While ✓ Decision Making => If else ✓ Arrays ✓ JSON object What’s common between Javascript and TypeScript? 21
  • 22. Variables - Typescript ✓ // The variable stores a value of type string
 var name:string = “mary”; ✓ // The variable is a string variable. The variable’s value is set to undefined by default
 var name:string; ✓ // The variable’s type is inferred from the data type of the value. Here, the variable is of the type string
 var name = “marry”; ✓ // The variable’s data type is any. Its value is set to undefined by default.
 var name; 22
  • 23. Functions #1 - Typescript ✓ // Function with optional parameter
 function disp_details(id:number,name:string,mail_id?:string) { console.log("ID:", id); console.log("Name",name); if(mail_id!=undefined) console.log("Email Id",mail_id); } 
 disp_details(123,"John"); disp_details(111,"mary","mary@xyz.com"); 23
  • 24. Functions #2 - Typescript ✓ // Function with rest parameter
 function addNumbers(…nums:number[ ]) { var i; var sum:number = 0; for (i = 0; i < nums.length; i++) { sum = sum + nums[ i ]; } console.log("sum of the numbers”, sum); } 
 addNumbers(1, 2, 3); addNumbers(10, 10, 10, 10, 10); 24
  • 25. Tuples - Typescript ✓ // Defining a tuple
 var myTuple = [ ]; ✓ // Defining a tuple and assigning values at same time
 var myTuple = [10, 20.3, “Angular JS”]; ✓ // Accessing a tuple value
 console.log(“Tuple at #2”, myTuple[2]);
 console.log(“Tuple at #0”, myTuple[0]);
 console.log(“Tuple at #1”, myTuple[1]); “Tuples are similar to Arrays but can store multiple data type in same variable” 25
  • 26. Union - Typescript ✓ // Defining a union
 var myUnion:string|number; ✓ // Assigning values to a union variable
 myUnion = 10;
 myUnion = “This is a string value assigned to Union variable”; “Union is the type of variable that can store more than one data type.” 26
  • 27. Interfaces - Typescript ✓ // Lets consider an object
 var person = { FirstName:"Tom", LastName:"Hanks", sayHi: ()=>{ return "Hi"} 
 }; ✓ To reuse the signature across objects we can define it as an interface. “An interface is a syntactical contract that an entity should conform to.” 27
  • 28. Interfaces Example interface IPerson { firstName:string, lastName:string, sayHi: ()=>string } var customer:IPerson = { firstName:"Tom", lastName:"Hanks", sayHi: ():string =>{return "Hi there"} } console.log("Customer Object ") console.log(customer.firstName) console.log(customer.lastName) console.log(customer.sayHi()) var employee:IPerson = { firstName:"Jim", lastName:"Blakes", sayHi: ():string =>{return "Hello!!!"} } console.log("Employee Object ") console.log(employee.firstName) console.log(employee.lastName); 28
  • 29. Classes - Typescript “A class in terms of OOP is a blueprint for creating objects. A class encapsulates data for the object.” class Car { //field engine:string; //constructor constructor(engine:string) { this.engine = engine } //function disp():void { console.log("Engine is : “ + this.engine); } } 29
  • 30. Namespaces - Typescript “A namespace is a way to logically group related code. It helps in resolving global namespace pollution problem presents in Javascript.” Example:- 
 namespace SomeNameSpaceName { export interface ISomeInterfaceName { } export class SomeClassName { } } “The classes or interfaces which should be accessed outside the namespace should be marked with keyword export.” 30
  • 31. Modules - Typescript “A module is designed with the idea to organise code written in TypeScript.” Internal External 31
  • 32. Internal Modules “Internal modules came in earlier version of Typescript and now replaced by namespaces.” 32
  • 33. External Modules “External modules in TypeScript exists to specify and load dependencies between multiple external JS files.” Example:- 
 import someInterfaceRef = require(“./SomeInterface”); There are two occasions when we need to load external JS files:- ➡ Server Side - NodeJs ➡ Client Side - RequireJs 33
  • 37. ngModule • Module is a group of components in Angular JS 2. • We can import one or more module in another module and all associated will automatically get imported. • We need not to worry about importing each component individually. “NgModules help organise an application into cohesive blocks of functionality” Features: 37
  • 38. ngModule • Feature as a Module • Shared Utilities as a Module How modules should be organised? There are no standard way to group modules, but the recommendations are: https://scotch.io/bar-talk/getting-to-know-angular-2s-module-ngmodule 38
  • 39. ngModule @NgModule({ declarations: [ // put all your components / directives / pipes here AppComponent, // the root component No1Component, No2Component, ... // e.g. put all 10 components here AComponent, BComponent, // e.g. put component A and B here NiceDirective, AwesomePipe, ], imports: [ // put all your modules here BrowserModule, // Angular 2 out of the box modules TranslateModule, // some third party modules / libraries ], providers: [ // put all your services here AwesomeService, ], bootstrap: [ // The main components to be bootstrapped in main.ts file, normally one only AppComponent ] }) export class AppModule { }
  • 40. Components “Encapsulate the template, data and the behaviour of view. Also known as view components” 40
  • 41. Directives “Modifies DOM elements and/or extend their behaviour” 41
  • 43. Services “Responsible for arranging data for view components” 43
  • 45. Components “Encapsulate the template, data and the behaviour of view. Also known as view components” { } Root Component { } { } { } { } { } 45
  • 47.
  • 48.
  • 49. Creating Component “Component can be creating using Angular CLI tool” Example:- 
 ng generate component my-new-component ng g component my-new-component # using the alias
 
 # components support relative path generation # if in the directory src/app/feature/ and you run ng g component new-cmp # your component will be generated in src/app/feature/new-cmp 
 # but if you were to run ng g component ../newer-cmp # your component will be generated in src/app/newer-cmp 49
  • 50. Signature for Component 50 ✓ Selector Name:- Tag name that needs to be searched in parent template ✓ Template URL:- Path of HTML template file associated with this component ✓ Style URLs:- String Array containing path of CSS files that are used to decorate this component. In component we need to define following details:-
  • 51. Component Example import { Component } from '@angular/core'; @Component({ moduleId: module.id, selector: 'selector-demo', templateUrl: 'demo.component.html', styleUrls: ['demo.component.css',
 'demo2.component.css'] }) export class DemoComponent { } 51
  • 52. Wrapping up ✓ Introduction to Angular JS ✓ Difference b/w Angular and Angular 2 and React JS ✓ Development Tools ✓ Basics of TypeScript ✓ Angular JS Architecture Topics Covered Next Session ๏ Passing data and events between components ๏ Directives and Pipes ๏ Model Classes ๏ Forms and Validation 52
  • 53.