SlideShare a Scribd company logo
ANGULAR 6

ARCHITECTURE & ORGANISATION DU CODE
Thibault Even - Expert Angular
ENVIRONNEMENT
• Typescript Language

• Visual Studio Code

• Angular CLI

• Plugins pour les projets Angular
• Angular Language Service

• angular2-inline

• angular v6 snippets

• prettier

• Material icon Theme / vscode-icons

• tslint

• trailing spaces
Plugins que j’utilise
pack de plugins
• Extensions packs et essentials packs
FROM SCRATCH
• Modules et composants

• Commandes CLI

• Architecture des dossiers
MODULE
COMPONENT
PIPE/

DIRECTIVE/

GUARDS
Modules et composants
MODULE 1
COMPONENT
PIPE/

DIRECTIVE/

GUARDS
Modules et composants
MODULE 2
MODULE 0
déclaration
import
export
DOMAIN

MODULE
ROUTING

MODULE
CORE

MODULE
Import unique dans app.module

Mettre tout les .forRoot() des modules tierce
SHARED

MODULE
Import dans tout les features modules

Composants et module partagés par les features modules
FEATURE

MODULE
Généralement attaché directement au app.module ou
indépendant par lazy-loading

Gère toute une partie de l’application : interface +
échange de donnée. ex : les commandes de produits
Commun à quelques features modules

Module en charge d’une fonctionnalité particulière qui
regroupe plusieurs components, services…
Module chargé de la déclaration des routes

Attaché à un feature module, optionnel, le forRoot doit
être dans le CoreModule
COMPONENT
CONTAINER
Composant chargé de récupérer et diffuser
la donnée dans les autres sous-composants

En relation avec le state-management ou les
services, pas d’input/output
Composant pouvant être utiliser dans
plusieurs application différentes

Ils ne demandent jamais la donnée
directement, ils ont des input et output pour les
événements à envoyer au composant parent

import { Component, OnInit, ChangeDetectionStrategy } from
'@angular/core';
import { Observable } from ‘rxjs';
import { FeatureService } from ‘../../services/feature.service';
import { Users } from '../../models/jsonpldr.model';
@Component({
…
})
export class Container1Component implements OnInit {
users$: Observable<Users>;
constructor(private api: FeatureService) {}
ngOnInit() {
this.users$ = this.api.getUsers();
}
CONTAINER
import { Component, OnInit, Input, Output,
EventEmitter } from '@angular/core';
@Component({
…
})
export class Component1Component implements OnInit {
@Input() data: string[];
@Output() selected = new EventEmitter<string>();
constructor() {}
ngOnInit() {}
onClick(item: string) {
this.selected.emit(item);
}
}
COMPONENT
Commandes CLI
•ng new 

•ng serve

•ng generate
•ng build

•ng update

•ng add
Commandes CLI : New
ng new ng6-project --style=scss
Commandes CLI : Serve
ng serve --port=4200
Meetup SkillValue - Angular 6 : Bien démarrer son application
Commandes CLI : Generate
ng generate
component
module
directive
guard
pipe
service
library
application
Commandes CLI : Generate
ng generate <schematics> --dryRun
L’option dryRun alias -d
Commandes CLI : Generate
ng generate library mysharedlib --prefix=my
La nouveauté : library
Commandes CLI : Build
ng build --prod
ng build --prod --build-optimizer
dist
Commandes CLI : Update
ng update
ng update rxjs
Commandes CLI : Add
ng add @angular/material
Ajout de la librairie ET intégration dans le code 

+ ajout de générateurs
Architecture ng6 : Multi App
ng generate application mysecondapp
Commandes CLI : WIKI
github.com/angular/angular-cli/wiki
Architecture angular 6
src (Main app)
projects (librairies, sub app)
Partage des librairies entre applications, 

maintenances indépendantes
Organisation intra-app
app
core
shared
app.module.tsts
Core / Shared principes
Organisation intra-app
Core Module - unique import, root modules cfg
core
containers
core.module.tsts
app
app.component.tsts
app.component.scss
Organisation intra-app
shared
components
shared.module.tsts
Shared Module - Composants / librairies transverses
pipes
directives
Organisation intra-app
app
core
shared
app.module.tsts
Clean architecture
Organisation intra-app
components
component1
component2
index.tsts
index.ts imports/exports
Organisation intra-app
index.ts imports/exports
index.tsts
import { Component1Component } from './component1/component1.component';
import { Component2Component } from './component2/component2.component';
import { Component3Component } from './component3/component3.component';
export const components = [
Component1Component,
Component2Component,
Component3Component
];
export * from './component1/component1.component';
export * from './component2/component2.component';
export * from './component3/component3.component';
Organisation intra-app
index.ts imports/exports
my.module.tsts
import * as fromComponents from './components';
@NgModule({
exports: [
...fromComponents.components,
],
declarations: [
...fromComponents.components,
]
})
export class MyModule {}
Organisation intra-app
app
core
shared
app.module.tsts
Libs folder
libs - domain modules directory
Organisation intra-app
app
core
shared
app.module.tsts
Domain / Features modules principes
feature module
Organisation intra-app
Feature module
feature
components
feature.module.tsts
containers
services
guards
feature.routing.tsts
Organisation intra-app
Feature module
feature.module.tsts
import { NgModule } from '@angular/core';
import { SharedModule } from '../shared/shared.module';
import { FeatureRoutingModule } from './feature.routing';
import * as fromComponents from './components';
import * as fromContainers from './containers';
import * as fromGuards from './guards';
@NgModule({
imports: [SharedModule, FeatureRoutingModule],
exports: [],
declarations:
[...fromComponents.components, ...fromContainers.containers],
providers: [...fromGuards.guards]
})
export class FeatureModule {}
Organisation intra-app
Feature module
feature.routing.tsts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import * as fromContainers from './containers';
const routes: Routes = [
{ path: '', component: fromContainers.Container1Component
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class FeatureRoutingModule {}
Organisation intra-app
lazy-loaded features modules
app.component.htmlhtml
<router-outlet></router-outlet>
Organisation intra-app
lazy-loaded features modules
core.routing.tsts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
export const routes: Routes = [
{ path: '**', redirectTo: 'feature' },
{
path: 'feature',
loadChildren: '../feature/feature.module#FeatureModule'
}
];
@NgModule({
imports: [RouterModule.forRoot(routes, { useHash: false })],
exports: [RouterModule]
})
export class CoreRoutingModule {}
Rxjs 6
refactoring des imports
// CREATION - RECREATION
import { Observable, throwError, BehaviorSubject } from ‘rxjs';
// OPERATORS
import { catchError, tap, map, retry, delay } from 'rxjs/operators';
Rxjs 6
using .pipe
getUsers() {
return this.httpClient
.get<Users>(this.api_url + '/users', {
observe: 'response'
})
.pipe(
delay(2000),
tap(response => console.log(response)),
map(response => response.body),
retry(2),
catchError((error: HttpErrorResponse) => throwError(error))
);
}
Pour aller plus loin
• https://github.com/ngrx/platform - State management - Redux pattern

• https://docs.nestjs.com/ - Nodejs framework inspiré par Angular

• https://www.apollographql.com/ - GraphQL client pour angular et bien
d’autres

• http://reactivex.io/rxjs/manual/overview.html#choose-an-
operator - Aide interactive pour choisir le bon operator Rxjs

• angular universal / angular PWA / angular Element /
Electron / Cordova /Capacitor
MERCI

A bientôt !
Thibault Even - Expert Angular


@thibault_ev

www.linkedin.com/in/thibault-even-543b3520

More Related Content

What's hot (20)

PDF
What's New in Angular 4 | Angular 4 Features | Angular 4 Changes | Angular Tu...
Edureka!
 
ODP
A Glimpse on Angular 4
Sam Dias
 
PDF
What angular 13 will bring to the table
Moon Technolabs Pvt. Ltd.
 
PPTX
Talk for DevFest 2021 - GDG Bénin
Ezéchiel Amen AGBLA
 
PDF
Angular Routing Tutorial | AngularJS vs Angular Router | Angular Training | E...
Edureka!
 
PDF
Developing a Demo Application with Angular 4 - J2I
Nader Debbabi
 
PDF
Introduction to angular 4
Marwane El Azami
 
PDF
Angular Day 2018 (italy) - Keynote - The Amazing World of Angular 6
Fabio Biondi
 
PPTX
Angular 9 New features
Ahmed Bouchefra
 
PDF
What’s new in angular 12[highlights of angular 12 features]
Katy Slemon
 
PPTX
Angular 4 Introduction Tutorial
Scott Lee
 
PDF
What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...
Edureka!
 
PDF
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Edureka!
 
PDF
Angular 2 - Core Concepts
Fabio Biondi
 
PDF
Angular 2: Migration - SSD 2016 London
Manfred Steyer
 
PDF
Angular 2 Examples | Angular CRUD Application | Angular Tutorial | Angular Tr...
Edureka!
 
PDF
Learn Angular 9/8 In Easy Steps
Ahmed Bouchefra
 
PDF
IVY: an overview
RobertoMontes31
 
PPTX
Angular 9
Raja Vishnu
 
PDF
Angular Advanced Routing
Laurent Duveau
 
What's New in Angular 4 | Angular 4 Features | Angular 4 Changes | Angular Tu...
Edureka!
 
A Glimpse on Angular 4
Sam Dias
 
What angular 13 will bring to the table
Moon Technolabs Pvt. Ltd.
 
Talk for DevFest 2021 - GDG Bénin
Ezéchiel Amen AGBLA
 
Angular Routing Tutorial | AngularJS vs Angular Router | Angular Training | E...
Edureka!
 
Developing a Demo Application with Angular 4 - J2I
Nader Debbabi
 
Introduction to angular 4
Marwane El Azami
 
Angular Day 2018 (italy) - Keynote - The Amazing World of Angular 6
Fabio Biondi
 
Angular 9 New features
Ahmed Bouchefra
 
What’s new in angular 12[highlights of angular 12 features]
Katy Slemon
 
Angular 4 Introduction Tutorial
Scott Lee
 
What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...
Edureka!
 
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Edureka!
 
Angular 2 - Core Concepts
Fabio Biondi
 
Angular 2: Migration - SSD 2016 London
Manfred Steyer
 
Angular 2 Examples | Angular CRUD Application | Angular Tutorial | Angular Tr...
Edureka!
 
Learn Angular 9/8 In Easy Steps
Ahmed Bouchefra
 
IVY: an overview
RobertoMontes31
 
Angular 9
Raja Vishnu
 
Angular Advanced Routing
Laurent Duveau
 

Similar to Meetup SkillValue - Angular 6 : Bien démarrer son application (20)

PPTX
Introduction to Angular2
Ivan Matiishyn
 
PPTX
Angular modules in depth
Christoffer Noring
 
PDF
What is your money doing?
Alfonso Fernández
 
PDF
Commit University - Exploring Angular 2
Commit University
 
PDF
Building Blocks of Angular 2 and ASP.NET Core
Levi Fuller
 
PDF
better-apps-angular-2-day1.pdf and home
ChethanGowda886434
 
PPTX
Angular2 + rxjs
Christoffer Noring
 
PPTX
Angular 2 Básico
Romualdo Andre
 
PDF
Angular 2 - The Next Framework
Commit University
 
PPTX
Angular 2 in-1
GlobalLogic Ukraine
 
PPTX
Angular js 2
Ran Wahle
 
PPTX
mean stack
michaelaaron25322
 
PPTX
Angular 2 Migration - JHipster Meetup 6
William Marques
 
PPTX
Building a TV show with Angular, Bootstrap, and Web Services
David Giard
 
PPTX
Creating custom Validators on Reactive Forms using Angular 6
AIMDek Technologies
 
PPTX
Angular 2.0
Mallikarjuna G D
 
PPTX
Angular Course.pptx
Imdad Ullah
 
PPTX
Jan 2017 - a web of applications (angular 2)
Kasper Reijnders
 
PDF
Angular meetup 2 2019-08-29
Nitin Bhojwani
 
PDF
02 - Angular Structural Elements - 1.pdf
BrunoOliveira631137
 
Introduction to Angular2
Ivan Matiishyn
 
Angular modules in depth
Christoffer Noring
 
What is your money doing?
Alfonso Fernández
 
Commit University - Exploring Angular 2
Commit University
 
Building Blocks of Angular 2 and ASP.NET Core
Levi Fuller
 
better-apps-angular-2-day1.pdf and home
ChethanGowda886434
 
Angular2 + rxjs
Christoffer Noring
 
Angular 2 Básico
Romualdo Andre
 
Angular 2 - The Next Framework
Commit University
 
Angular 2 in-1
GlobalLogic Ukraine
 
Angular js 2
Ran Wahle
 
mean stack
michaelaaron25322
 
Angular 2 Migration - JHipster Meetup 6
William Marques
 
Building a TV show with Angular, Bootstrap, and Web Services
David Giard
 
Creating custom Validators on Reactive Forms using Angular 6
AIMDek Technologies
 
Angular 2.0
Mallikarjuna G D
 
Angular Course.pptx
Imdad Ullah
 
Jan 2017 - a web of applications (angular 2)
Kasper Reijnders
 
Angular meetup 2 2019-08-29
Nitin Bhojwani
 
02 - Angular Structural Elements - 1.pdf
BrunoOliveira631137
 
Ad

Recently uploaded (20)

PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PDF
Infrastructure planning and resilience - Keith Hastings.pptx.pdf
Safe Software
 
PDF
SAP GUI Installation Guide for Windows | Step-by-Step Setup for SAP Access
SAP Vista, an A L T Z E N Company
 
PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PPTX
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
PDF
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PDF
Troubleshooting Virtual Threads in Java!
Tier1 app
 
PDF
Virtual Threads in Java: A New Dimension of Scalability and Performance
Tier1 app
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
Infrastructure planning and resilience - Keith Hastings.pptx.pdf
Safe Software
 
SAP GUI Installation Guide for Windows | Step-by-Step Setup for SAP Access
SAP Vista, an A L T Z E N Company
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
Presentation about variables and constant.pptx
kr2589474
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
Presentation about Database and Database Administrator
abhishekchauhan86963
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Activate_Methodology_Summary presentatio
annapureddyn
 
Troubleshooting Virtual Threads in Java!
Tier1 app
 
Virtual Threads in Java: A New Dimension of Scalability and Performance
Tier1 app
 
Ad

Meetup SkillValue - Angular 6 : Bien démarrer son application