\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{Jeanvaljean (Mobbigdick)} \pdfinfo{ /Title (angular-js-to-angular.pdf) /Creator (Cheatography) /Author (Jeanvaljean (Mobbigdick)) /Subject (Angular JS to Angular 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}{1C1C1C} \definecolor{LightBackground}{HTML}{F7F7F7} \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 JS to Angular Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Jeanvaljean (Mobbigdick)} via \textcolor{DarkBackground}{\uline{cheatography.com/67522/cs/16985/}}} \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}Jeanvaljean (Mobbigdick) \\ \uline{cheatography.com/mobbigdick} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 7th September, 2018.\\ 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{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Template Basics}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Bindings/interpolation}} & {\bf{Bindings/interpolation}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Your favorite hero is: \{\{vm.favoriteHero\}\} & Your favorite hero is: \{\{vm.favoriteHero\}\} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} {\bf{Filters}} & {\bf{Pipes}} \tn % Row Count 6 (+ 1) % Row 3 \SetRowColor{white} \textless{}td\textgreater{}\{\{movie.title | uppercase\}\}\textless{}/td\textgreater{} & \textless{}td\textgreater{}\{\{movie.title | uppercase\}\}\textless{}/td\textgreater{} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{Local variables}} & {\bf{Input variables}} \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} \textless{}tr ng-repeat="movie in vm.movies"\textgreater{}\{\{nl\}\}\textless{}td\textgreater{}\{\{movie.title\}\}\textless{}/td\textgreater{}\{\{nl\}\}\textless{}/tr\textgreater{} & \textless{}tr *ngFor="let movie of movies"\textgreater{}\{\{nl\}\}\textless{}td\textgreater{}\{\{movie.title\}\}\textless{}/td\textgreater{}\{\{nl\}\}\textless{}/tr\textgreater{} \tn % Row Count 13 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Template directives}} \tn % Row 0 \SetRowColor{LightBackground} -{}-{}-{}-{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}- & -{}-{}-{}-{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}--{}-{}- \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} {\bf{ng-class}} & {\bf{ngClass}} \tn % Row Count 6 (+ 1) % Row 2 \SetRowColor{LightBackground} \textless{}div ng-class="\{active: isActive\}"\textgreater{}\{\{nl\}\}\textless{}div ng-class="\{active: isActive, shazam: isImportant\}"\textgreater{} & \textless{}div {[}ngClass{]}="\{'active': isActive\}"\textgreater{}\{\{nl\}\}\textless{}div {[}ngClass{]}="\{'active': isActive, 'shazam': isImportant\}"\textgreater{}\{\{nl\}\}\textless{}div {[}class.active{]}="isActive"\textgreater{} \tn % Row Count 14 (+ 8) % Row 3 \SetRowColor{white} {\bf{ng-click}} & {\bf{Bind to `click` event}} \tn % Row Count 16 (+ 2) % Row 4 \SetRowColor{LightBackground} \textless{}button ng-click="vm.toggleImage()"\textgreater{}\{\{nl\}\}\textless{}button ng-click="vm.toggleImage(\$event)"\textgreater{} & \textless{}button (click)="toggleImage()"\textgreater{}\{\{nl\}\}\textless{}button (click)="toggleImage(\$event)"\textgreater{} \tn % Row Count 21 (+ 5) % Row 5 \SetRowColor{white} {\bf{ng-controller}} & {\bf{Component Decorator}} \tn % Row Count 23 (+ 2) % Row 6 \SetRowColor{LightBackground} \textless{}div \seqsplit{ng-controller="MovieListCtrl} as vm"\textgreater{} & @Component(\{\{\{nl\}\}selector: 'app-movie-list',\{\{nl\}\}templateUrl: \seqsplit{'./movie-list.component.html'},\{\{nl\}\}styleUrls: {[} \seqsplit{'./movie-list.component.css'} {]},\{\{nl\}\}\}) \tn % Row Count 31 (+ 8) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Template directives (cont)}} \tn % Row 7 \SetRowColor{LightBackground} {\bf{ng-href}} & {\bf{Bind to `href` property}} \tn % Row Count 2 (+ 2) % Row 8 \SetRowColor{white} \textless{}a ng-href="\{\{ angularDocsUrl \}\}"\textgreater{}Angular Docs\textless{}/a\textgreater{} & \textless{}a {[}href{]}="angularDocsUrl"\textgreater{}Angular Docs\textless{}/a\textgreater{} \tn % Row Count 5 (+ 3) % Row 9 \SetRowColor{LightBackground} {\bf{ng-if}} & {\bf{*ngIf}} \tn % Row Count 6 (+ 1) % Row 10 \SetRowColor{white} \textless{}table ng-if="movies.length"\textgreater{} & \textless{}table *ngIf="movies.length"\textgreater{} \tn % Row Count 8 (+ 2) % Row 11 \SetRowColor{LightBackground} {\bf{ng-model}} & {\bf{ngModel}} \tn % Row Count 9 (+ 1) % Row 12 \SetRowColor{white} \textless{}input ng-model="vm.favoriteHero"/\textgreater{} & \textless{}input {[}(ngModel){]}="favoriteHero" /\textgreater{} \tn % Row Count 11 (+ 2) % Row 13 \SetRowColor{LightBackground} {\bf{ng-repeat}} & {\bf{*ngFor}} \tn % Row Count 12 (+ 1) % Row 14 \SetRowColor{white} \textless{}tr ng-repeat="movie in vm.movies"\textgreater{} & \textless{}tr *ngFor="let movie of movies"\textgreater{} \tn % Row Count 14 (+ 2) % Row 15 \SetRowColor{LightBackground} {\bf{ng-show}} & {\bf{Bind to `hidden` property}} \tn % Row Count 16 (+ 2) % Row 16 \SetRowColor{white} \textless{}h3 ng-show="vm.favoriteHero"\textgreater{}\{\{nl\}\}Your favorite hero is: \{\{vm.favoriteHero\}\}\{\{nl\}\}\textless{}/h3\textgreater{} & \textless{}h3 {[}hidden{]}="!favoriteHero"\textgreater{}\{\{nl\}\}Your favorite hero is: \{\{favoriteHero\}\}\{\{nl\}\}\textless{}/h3\textgreater{} \tn % Row Count 21 (+ 5) % Row 17 \SetRowColor{LightBackground} {\bf{ng-src}} & {\bf{Bind to `src` property}} \tn % Row Count 23 (+ 2) % Row 18 \SetRowColor{white} \textless{}img ng-src="\{\{movie.imageurl\}\}"\textgreater{} & \textless{}img {[}src{]}="movie.imageurl"\textgreater{} \tn % Row Count 25 (+ 2) % Row 19 \SetRowColor{LightBackground} {\bf{ng-style}} & {\bf{ngStyle}} \tn % Row Count 26 (+ 1) % Row 20 \SetRowColor{white} \textless{}div ng-style="\{color: colorPreference\}"\textgreater{} & \textless{}div {[}ngStyle{]}="\{'color': colorPreference\}"\textgreater{}\{\{nl\}\}\textless{}div {[}style.color{]}="colorPreference"\textgreater{} \tn % Row Count 31 (+ 5) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Template directives (cont)}} \tn % Row 21 \SetRowColor{LightBackground} {\bf{ng-switch}} & {\bf{{[}ngSwitch{]}}} \tn % Row Count 1 (+ 1) % Row 22 \SetRowColor{white} \textless{}div \seqsplit{ng-switch="vm.favoriteHero} \&\&\{\{nl\}\}vm.checkMovieHero(vm.favoriteHero)"\textgreater{}\{\{nl\}\}\textless{}div ng-switch-when="true"\textgreater{}\{\{nl\}\}Excellent choice!\{\{nl\}\}\textless{}/div\textgreater{}\{\{nl\}\}\textless{}div ng-switch-when="false"\textgreater{}\{\{nl\}\}No movie, sorry!\{\{nl\}\}\textless{}/div\textgreater{}\{\{nl\}\}\textless{}div ng-switch-default\textgreater{}\{\{nl\}\}Please enter your favorite hero.\{\{nl\}\}\textless{}/div\textgreater{}\{\{nl\}\}\textless{}/div\textgreater{} & \textless{}span {[}ngSwitch{]}="favoriteHero \&\&\{\{nl\}\}checkMovieHero(favoriteHero)"\textgreater{}\{\{nl\}\}\textless{}p {\emph{ngSwitchCase="true"\textgreater{}\{\{nl\}\}Excellent choice!\{\{nl\}\}\textless{}/p\textgreater{}\{\{nl\}\}\textless{}p }}ngSwitchCase="false"\textgreater{}\{\{nl\}\}No movie, sorry!\{\{nl\}\}\textless{}/p\textgreater{}\{\{nl\}\}\textless{}p *ngSwitchDefault\textgreater{}\{\{nl\}\}Please enter your favorite hero.\{\{nl\}\}\textless{}/p\textgreater{}\{\{nl\}\}\textless{}/span\textgreater{} \tn % Row Count 17 (+ 16) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Filters/pipes}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Currency}} & {\bf{Currency}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \textless{}td\textgreater{}\{\{movie.price | currency\}\}\textless{}/td\textgreater{} & \textless{}td\textgreater{}\{\{movie.price | currency:'USD':true\}\}\textless{}/td\textgreater{} \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} {\bf{Date}} & {\bf{Date}} \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} \textless{}td\textgreater{}\{\{movie.releaseDate | date\}\}\textless{}/td\textgreater{} & \textless{}td\textgreater{}\{\{movie.releaseDate | date\}\}\textless{}/td\textgreater{} \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{Filter}} & {\bf{None}} \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} \textless{}tr ng-repeat="movie in movieList | filter: \{title:listFilter\}"\textgreater{} & If you need the same filtering code in several templates,\{\{nl\}\}consider building a custom pipe. \tn % Row Count 13 (+ 5) % Row 6 \SetRowColor{LightBackground} {\bf{json}} & {\bf{json}} \tn % Row Count 14 (+ 1) % Row 7 \SetRowColor{white} \textless{}pre\textgreater{}\{\{movie | json\}\}\textless{}/pre\textgreater{} & \textless{}pre\textgreater{}\{\{movie | json\}\}\textless{}/pre\textgreater{} \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} {\bf{Limit to}} & {\bf{Slice}} \tn % Row Count 17 (+ 1) % Row 9 \SetRowColor{white} \textless{}tr ng-repeat="movie in movieList | limitTo:2:0"\textgreater{} & \textless{}tr *ngFor="let movie of movies | slice:0:2"\textgreater{} \tn % Row Count 20 (+ 3) % Row 10 \SetRowColor{LightBackground} {\bf{LowerCase}} & {\bf{LowerCase}} \tn % Row Count 21 (+ 1) % Row 11 \SetRowColor{white} \textless{}td\textgreater{}\{\{movie.title | lowercase\}\}\textless{}/td\textgreater{} & \textless{}td\textgreater{}\{\{movie.title | lowercase\}\}\textless{}/td\textgreater{} \tn % Row Count 23 (+ 2) % Row 12 \SetRowColor{LightBackground} {\bf{Number}} & {\bf{Number}} \tn % Row Count 24 (+ 1) % Row 13 \SetRowColor{white} \textless{}td\textgreater{}\{\{movie.starRating | number\}\}\textless{}/td\textgreater{} & \textless{}td\textgreater{}\{\{movie.starRating | number\}\}\textless{}/td\textgreater{}\{\{nl\}\}\textless{}td\textgreater{}\{\{movie.starRating | number:'1.1-2'\}\}\textless{}/td\textgreater{}\{\{nl\}\}\textless{}td\textgreater{}\{\{movie.approvalRating | percent: '1.0-2'\}\}\textless{}/td\textgreater{} \tn % Row Count 32 (+ 8) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Filters/pipes (cont)}} \tn % Row 14 \SetRowColor{LightBackground} {\bf{OrderBy}} & {\bf{None}} \tn % Row Count 1 (+ 1) % Row 15 \SetRowColor{white} \textless{}tr ng-repeat="movie in movieList | orderBy : 'title'"\textgreater{} & If you need the same ordering or sorting code in several templates,\{\{nl\}\}consider building a custom pipe. \tn % Row Count 7 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{\seqsplit{Modules/controllers/components}}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{IIFE}} & {\bf{None}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} (function () \{ ... \}()); & This is a nonissue in Angular because ES 2015 modules handle the namespacing for you. \tn % Row Count 6 (+ 5) % Row 2 \SetRowColor{LightBackground} {\bf{Angular Modules}} & {\bf{NgModules}} \tn % Row Count 7 (+ 1) % Row 3 \SetRowColor{white} \seqsplit{angular.module("movieHunter"}, {[}"ngRoute"{]}); & import \{ NgModule \}\{\{nl\}\}from '@angular/core';\{\{nl\}\}import \{ BrowserModule \} from '@angular/platform-browser';\{\{nl\}\} import \{ AppComponent \} from './app.component';\{\{nl\}\}@NgModule(\{\{\{nl\}\}imports: {[} BrowserModule {]},\{\{nl\}\}declarations: {[} AppComponent {]},\{\{nl\}\}bootstrap: {[} AppComponent {]}\{\{nl\}\}\})\{\{nl\}\}export class AppModule \{ \} \tn % Row Count 24 (+ 17) % Row 4 \SetRowColor{LightBackground} {\bf{Controller Registration}} & {\bf{Component Decorator}} \tn % Row Count 26 (+ 2) % Row 5 \SetRowColor{white} angular\{\{nl\}\}.module("movieHunter")\{\{nl\}\}.controller("MovieListCtrl",\{\{nl\}\}{[}"movieService",\{\{nl\}\}MovieListCtrl{]}); & @Component(\{\{\{nl\}\}selector: 'app-movie-list',\{\{nl\}\}templateUrl: \seqsplit{'./movie-list.component.html'},\{\{nl\}\}styleUrls: {[} \seqsplit{'./movie-list.component.css'} {]},\{\{nl\}\}\}) \tn % Row Count 34 (+ 8) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{\seqsplit{Modules/controllers/components} (cont)}} \tn % Row 6 \SetRowColor{LightBackground} {\bf{Controller Function}} & {\bf{Component Class}} \tn % Row Count 2 (+ 2) % Row 7 \SetRowColor{white} function \seqsplit{MovieListCtrl(movieService)} \{\{\{nl\}\}\} & export class MovieListComponent \{\{\{nl\}\}\} \tn % Row Count 5 (+ 3) % Row 8 \SetRowColor{LightBackground} {\bf{Dependency Injection}} & {\bf{Dependency Injection}} \tn % Row Count 7 (+ 2) % Row 9 \SetRowColor{white} \seqsplit{MovieListCtrl.\$inject} = {[}'MovieService'{]};\{\{nl\}\}function \seqsplit{MovieListCtrl(movieService)} \{\{\{nl\}\}\} & \seqsplit{constructor(movieService:} MovieService) \{\{\{nl\}\}\} \tn % Row Count 12 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Styles Sheets}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Link Tag}} & {\bf{Style Configuration}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \textless{}link href="styles.css" rel="stylesheet" /\textgreater{} & "styles": {[}\{\{nl\}\}"styles.css"\{\{nl\}\}{]}, \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} & {\bf{Style Urls}} \tn % Row Count 6 (+ 1) % Row 3 \SetRowColor{white} & styleUrls: {[} \seqsplit{'./movie-list.component.css'} {]}, \tn % Row Count 9 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \end{document}