01 - Introduction To Angular
01 - Introduction To Angular
Unit 1
Introduction to Angular
Introduction to Angular
Outline
What is Angular ?
Angular Architecture
What is MVVM ?
M.Romdhani, 2022 2
1
Unit 1- Introduction to Angular
What is Angular ?
Introduction to Angular
What is Angular ?
Angular is a development framework for building mobile and
desktop web applications.
It's a large development platform
Angular is Cross platform
General Web Applications
Mobile Web (responsive)
Android / iOS: Native with NativeScript & Ionic 2 Native
Windows / Mac / Linux: Desktop using Electron
M.Romdhani, 2022 4
2
Unit 1- Introduction to Angular
Introduction to Angular
Angular History
Angular 2.0 and above are now simply called “Angular”, any 1.0
version is “AngularJS”.
Angular 2 is a complete rewrite of AngularJS but Angular 4 is an upgrade
of Angular 2. There exist no Angular 3 version !
Angular 2 has been released in September 2016
Angular 4 has been released in March 2017
…
Angular 11 has been released in November 2020
Angular 12 has been released in May 2021
M.Romdhani, 2022 5
Introduction to Angular
What is TypeScript?
Superset of JavaScript
It was designed by Anders Hejlsberg (designer of C#) at Microsoft.
The first version (0.8) was released in 2012. TypeScript is both a
language and a set of tools
Compiles to plain JavaScript
Transpilation
Strongly typed
Primitives: boolean, number, string, void,
null, undefined
Objects: array, enum, classes,
interfaces
The Any type: In some situations,
not all type information is available.
Class-based object-orientation
M.Romdhani, 2022 6
3
Unit 1- Introduction to Angular
Introduction to Angular
Angular Architecture
Angular is a platform and framework for building client
applications in HTML and TypeScript. Angular is written in
TypeScript. It implements core and optional functionality as a set
of TypeScript libraries that you import into your apps.
https://angular.io/generated/images/guide/architecture/overview2.png
M.Romdhani, 2022 8
4
Unit 1- Introduction to Angular
Introduction to Angular
Basic Building blocs : Modules and
Components
The basic building blocks of an Angular application are NgModules,
which provide a compilation context for components.
M.Romdhani, 2022 9
10
5
Unit 1- Introduction to Angular
Introduction to Angular
Angular modules
M.Romdhani, 2022 11
11
Introduction to Angular
Components
M.Romdhani, 2022 12
12
6
Unit 1- Introduction to Angular
Introduction to Angular
Components in Angular
Components are the building blocks of your application. Imagine
building a site like Amazon.com:
M.Romdhani, 2022 13
13
Introduction to Angular
Business
Logic and
Data • Data Access
• Update ViewModel about
change
M.Romdhani, 2022 14
14
7
Unit 1- Introduction to Angular
15
Introduction to Angular
The services provide the logic for
components
M.Romdhani, 2022 16
16
8
Unit 1- Introduction to Angular
Introduction to Angular
M.Romdhani, 2022 17
17
Routing
18
9
Unit 1- Introduction to Angular
Introduction to Angular
M.Romdhani, 2022 19
19
Introduction to Angular
Routing basics
Configuration
A routed Angular application has
one singleton instance of the
Router service. When the
browser's URL changes, that
router looks for a corresponding
Route from which it can determine
the component to display.
A router has no routes until you
configure it. The following example
creates five route definitions,
configures the router via the
RouterModule.forRoot() method,
and adds the result to the
AppModule's imports array.
M.Romdhani, 2022 20
20
10
Unit 1- Introduction to Angular
Introduction to Angular
Routing basics
The appRoutes array of routes describes how to navigate.
Pass it to the RouterModule.forRoot() method in the module imports to
configure the router.
M.Romdhani, 2022 21
21
Angular Installation
22
11
Unit 1- Introduction to Angular
Introduction to Angular
Installation
npm install -g @angular/cli
(This installs the latest stable version)
Usage
ng help
You can configure the default HTTP host and port used by the development
server with two command-line options :
ng serve --host 0.0.0.0 --port 4201
M.Romdhani, 2022 23
23
Introduction to Angular
Generating Components, Directives,
Pipes and Services
You can use the ng generate (or just ng g) command to generate
Angular components:
M.Romdhani, 2022 24
24
12
Unit 1- Introduction to Angular
Introduction to Angular
Generating Components, Directives,
Pipes and Services
You can find all possible blueprints in the table below:
M.Romdhani, 2022 25
25
26
13
Unit 1- Introduction to Angular
Introduction to Angular
M.Romdhani, 2022 27
27
Introduction to Angular
Package.json
Each npm project has a package.json that contains meta-data for the
project, the scripts, and the dependencies
Dependencies vs. DevDependencies
Dependencies are to be used for production.
DevDependencies are to be used for development/quality/tests.
Package-lock.json contains the exact versions of Packages
package-lock.json is not meant to be read line-by-line by developers (unless
we're desperate to resolve "works in my machine" issues)
28
14
Unit 1- Introduction to Angular
Introduction to Angular
M.Romdhani, 2022 29
29
Introduction to Angular
Install Bootstrap
npm install --save bootstrap
Install Font-awesome
npm install --save font-awesome
$fa-font-path: "~font-awesome/fonts";
@import "~font-awesome/scss/font-awesome";
30
15