\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Kelem} \pdfinfo{ /Title (angular-2-demarrer-un-projet.pdf) /Creator (Cheatography) /Author (Kelem) /Subject (Angular 2 - Démarrer un projet Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{406EA3} \definecolor{LightBackground}{HTML}{F3F5F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Angular 2 - Démarrer un projet Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Kelem} via \textcolor{DarkBackground}{\uline{cheatography.com/25389/cs/6630/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Kelem \\ \uline{cheatography.com/kelem} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 13th January, 2016.\\ Updated 13th May, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Fichier package.json}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{ \newline "name": "bootstrap", \newline "version": "1.0.0", \newline "scripts": \{ \newline "tsc": "tsc", \newline "tsc:w": "tsc -w", \newline "lite": "lite-server", \newline "start": "concurrent \textbackslash{}"npm run tsc:w\textbackslash{}" \textbackslash{}"npm run lite\textbackslash{}" " \newline \}, \newline "license": "ISC", \newline "dependencies": \{ \newline "angular2": "2.0.0-beta.0", \newline "systemjs": "0.19.6", \newline "es6-promise": "\textasciicircum{}3.0.2", \newline "es6-shim": "\textasciicircum{}0.33.3", \newline "reflect-metadata": "0.1.2", \newline "rxjs": "5.0.0-beta.0", \newline "zone.js": "0.5.10" \newline \}, \newline "devDependencies": \{ \newline "concurrently": "\textasciicircum{}1.0.0", \newline "lite-server": "\textasciicircum{}1.3.1", \newline "typescript": "\textasciicircum{}1.7.3" \newline \} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Explications package.json}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{Ce fichier permet de charger les dépendances nécessaires pour le projet. On trouve dans ce fichier : \newline % Row Count 3 (+ 3) Les scripts disponibles : \newline % Row Count 4 (+ 1) * tsc : Compilation du code TypeScript \newline % Row Count 5 (+ 1) * tsc:w : Compilation du code TypeScript avec un watcher sur les changements \newline % Row Count 7 (+ 2) * lite : Démarrage d'un serveur http {\bf{lite}} \newline % Row Count 8 (+ 1) * start : Démarrage de la compilation avec watcher et du serveur de manière concurrentielle \newline % Row Count 10 (+ 2) Les dépendances : \newline % Row Count 11 (+ 1) * angular2 \newline % Row Count 12 (+ 1) * systemjs : Permet le chargement dynamique de module \newline % Row Count 14 (+ 2) * es6-promise : Promises \newline % Row Count 15 (+ 1) * es6-shim : Polyfills permettant d'émuler certaines fonctionnalités sur des navigateurs non compatibles \newline % Row Count 18 (+ 3) * reflect-metadata : Permet d'ajouter des décorateurs \newline % Row Count 20 (+ 2) * rxjs : Reactive Programming \newline % Row Count 21 (+ 1) * zone.js : Equivalent des threads locals en Java \newline % Row Count 22 (+ 1) Les dépendances de développement : \newline % Row Count 23 (+ 1) * concurrently : Pour démarrer des scripts de manière concurrente \newline % Row Count 25 (+ 2) * lite-server \newline % Row Count 26 (+ 1) * typescript% Row Count 27 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Fichier tsconfig.json}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{ \newline "compilerOptions": \{ \newline "module": "system", \newline "target": "es5", \newline "moduleResolution": "node", \newline "sourceMap": true, \newline "emitDecoratorMetadata": true, \newline \seqsplit{"experimentalDecorators":} true, \newline "removeComments": false, \newline "noImplicitAny": false \newline \}, \newline "exclude": {[} \newline "node\_modules" \newline {]} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{Permet de spécifier des options pour la compilation du TypeScript en JavaScript. Voir les ressources suivantes : \newline \newline https://github.com/Microsoft/TypeScript/wiki/tsconfig.json \newline https://github.com/Microsoft/TypeScript/wiki/Compiler-Options} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Création d'un composant}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{import \{Component\} from "angular2/core"; \newline \newline @Component(\{ \newline selector: 'my-app', \newline template: '\textless{}h1\textgreater{}My first Angular 2 App\textless{}/h1\textgreater{}' \newline \}) \newline export class AppComponent \{\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{Les étapes sont : \newline {\emph{ Imports \newline }} Décorateurs \newline * Classes} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Fichier boot.ts}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{import \{bootstrap\} from \seqsplit{"angular2/platform/browser";} \newline import \{AppComponent\} from "./app.component"; \newline \newline bootstrap(AppComponent);} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{Ce fichier permet de {\emph{booter}} notre application. On boote notre composant principal. Attention à bien utiliser \seqsplit{angular2/platform/browser}.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Fichier index.html}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\textless{}html\textgreater{} \newline \newline \textless{}head\textgreater{} \newline \textless{}title\textgreater{}Angular 2 QuickStart\textless{}/title\textgreater{} \newline \newline \textless{}!-{}- 1. Load libraries -{}-\textgreater{} \newline \textless{}script \seqsplit{src="node\_modules/angular2/bundles/angular2-polyfills}.js"\textgreater{}\textless{}/script\textgreater{} \newline \textless{}script \seqsplit{src="node\_modules/systemjs/dist/system}.src.js"\textgreater{}\textless{}/script\textgreater{} \newline \textless{}script \seqsplit{src="node\_modules/rxjs/bundles/Rx}.js"\textgreater{}\textless{}/script\textgreater{} \newline \textless{}script \seqsplit{src="node\_modules/angular2/bundles/angular2}.dev.js"\textgreater{}\textless{}/script\textgreater{} \newline \newline \textless{}!-{}- 2. Configure SystemJS -{}-\textgreater{} \newline \textless{}script\textgreater{} \newline System.config(\{ \newline packages: \{ \newline app: \{ \newline format: 'register', \newline defaultExtension: 'js' \newline \} \newline \} \newline \}); \newline \seqsplit{System.import('app/boot')} \newline .then(null, \seqsplit{console.error.bind(console));} \newline \textless{}/script\textgreater{} \newline \newline \textless{}/head\textgreater{} \newline \newline \textless{}!-{}- 3. Display the application -{}-\textgreater{} \newline \textless{}body\textgreater{} \newline \textless{}my-app\textgreater{}Loading...\textless{}/my-app\textgreater{} \newline \textless{}/body\textgreater{} \newline \newline \textless{}/html\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\emph{ Chargement des librairies nécessaires \newline }} Chargement du module via SystemJS \newline * Affichage de notre composant} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Récapitulatif}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{On créé un nouveau projet vide dans Webstorm. \newline % Row Count 1 (+ 1) On créé un fichier package.json pour les dépendances. \newline % Row Count 3 (+ 2) On créé ensuite un tsconfig.json qui va permettre la compilation TypeScript en Javascript (Plus précisément la transpilation). \newline % Row Count 6 (+ 3) On créé notre composant angular. \newline % Row Count 7 (+ 1) On créé ensuite un fichier boot.ts pour gérer le bootstrap de notre application. \newline % Row Count 9 (+ 2) On termine par la création de notre page index.html.% Row Count 11 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \end{document}