Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Ultimate Getting Started with Angular Works...

The Ultimate Getting Started with Angular Workshop - Devoxx France 2017

These slides are from a workshop I did at Devoxx France 2017. I showed how to set up an Angular development environment from scratch, develop a simple app, test it, integrating CSS frameworks (Angular Material and Bootstrap 4), secure it with OpenID Connect, and deploy it to the cloud.

Source code and tutorial: https://github.com/mraible/ng-demo

Matt Raible

April 05, 2017
Tweet

More Decks by Matt Raible

Other Decks in Technology

Transcript

  1. Blogger on raibledesigns.com Java Champion and Web Developer Father, Skier,

    Mountain Biker, Whitewater Rafter Open Source Connoisseur Who is Matt Raible? Bus Lover Okta Developer Advocate
  2. #DevoxxFR Jobs on LinkedIn (US) April 2017 0 2,000 4,000

    6,000 8,000 Backbone AngularJS Ember Knockout React Vue
  3. #DevoxxFR Jobs on LinkedIn (US) April 2017 0 3,500 7,000

    10,500 14,000 Backbone Angular Ember Knockout React Vue
  4. #DevoxxFR Stack Overflow Tags April 2017 0 75,000 150,000 225,000

    300,000 Backbone Angular Knockout Ember React
  5. #DevoxxFR Hello World with AngularJS <!doctype html> <html ng-app> <head>

    <title>Hello World</title> </head> <body> <div> <label>Name:</label> <input type="text" ng-model="name" placeholder="Enter a name here"> <hr> <h1>Hello {{name}}!</h1> </div> <script src="http://code.angularjs.org/1.5.8/angular.min.js"></script> </body> </html>
  6. #DevoxxFR Hello World with Angular <!DOCTYPE html> <html> <head> <title>Angular

    QuickStart</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="styles.css"> <!-- Polyfill(s) for older browsers --> <script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/zone.js/dist/zone.js"></script> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('app').catch(function(err){ console.error(err); }); </script> </head> <body> <my-app>Loading AppComponent content here ...</my-app> </body> </html>
  7. #DevoxxFR app/main.ts import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import {

    AppModule } from './app.module'; platformBrowserDynamic().bootstrapModule(AppModule);
  8. #DevoxxFR app/app.module.ts import { NgModule } from '@angular/core'; import {

    BrowserModule } from '@angular/platform-browser'; import { AppComponent } from './app.component'; @NgModule({ imports: [ BrowserModule ], declarations: [ AppComponent ], bootstrap: [ AppComponent ] }) export class AppModule { }
  9. #DevoxxFR app/app.component.ts import { Component } from '@angular/core'; @Component({ selector:

    'my-app', template: `<h1>Hello {{name}}</h1>`, }) export class AppComponent { name = 'Angular'; }
  10. #DevoxxFR Angular 2+ Choices Choose a language JavaScript (ES6 or

    ES5) TypeScript Dart Anything that transpiles to JS Setup dev environment Install Node Choose Package Manager Choose Module Loader Choose Transpiler Choose Build Tool
  11. #DevoxxFR ES6, ES7 and TypeScript TS ES7 ES6 ES5 ES5:

    es5.github.io ES6: git.io/es6features ES7: DRAFT TS: www.typescriptlang.org
  12. #DevoxxFR TypeScript $ npm install -g typescript function greeter(person: string)

    {
 return "Hello, " + person;
 }
 
 var user = "Jane User";
 
 document.body.innerHTML = greeter(user); $ tsc greeter.ts https://www.typescriptlang.org/docs/tutorial.html
  13. #DevoxxFR Easiest ways to get started Angular QuickStart https://github.com/angular/quickstart Angular

    Seed https://github.com/mgechev/angular-seed Angular CLI https://github.com/angular/angular-cli
  14. #DevoxxFR Built-in Components <div *ngIf="str == 'yes'"></div> <div [ngSwitch]="myVar"> <div

    *ngSwitchWhen="'A'"></div> </div> <div [ngStyle]="{color: colorinput.value}"></div> <div [ngClass]="{bordered: true}"></div> <div *ngFor="let item of items; let num = index"></div>
  15. #DevoxxFR The asterisk (*) effect <!-- Examples (A) and (B)

    are the same --> <!-- (A) *ngIf paragraph --> <p *ngIf="condition"> Our heroes are true! </p> <!-- (B) [ngIf] with template --> <template [ngIf]="condition"> <p> Our heroes are true! </p> </template>
  16. #DevoxxFR Angular Forms Template-Driven import { FormsModule } from '@angular/forms';

    Reactive Forms import { ReactiveFormsModule } from '@angular/forms';
  17. #DevoxxFR Template-Driven Validation <label for="name">Name</label> <input type="text" class="form-control" id="name" required

    [(ngModel)]="model.name" name="name" #name="ngModel" > <div [hidden]="name.valid || name.pristine" class="alert alert-danger"> Name is required </div>
  18. #DevoxxFR Reactive Forms Validation <form [formGroup]="heroForm" *ngIf="active" (ngSubmit)="onSubmit()"> <label for="name">Name</label>

    <input type="text" id="name" class="form-control" formControlName="name" required > <div *ngIf="formErrors.name" class="alert alert-danger"> {{ formErrors.name }} </div> </form>
  19. #DevoxxFR Observables and RxJS Promises emit a single value whereas

    streams emit many values Imperative code “pulls” data whereas reactive streams “push” data RxJS is functional Streams are composable
  20. #DevoxxFR Upgrading from AngularJS to Angular Big Bang Incremental ngUpgrade

    import {UpgradeAdapter} from ‘@angular/upgrade'; var adapter = new UpgradeAdapter(); var app = angular.module('myApp', []); adapter.bootstrap(document.body, ['myApp']);
  21. #DevoxxFR Lab: Create an Angular Project Create a project Run

    the application Add a search feature Add an edit feature Add validation http://bit.ly/ng-create
  22. #DevoxxFR Quality “A person who knows how to fix motorcycles—with

    Quality—is less likely to run short of friends than one who doesn't. And they aren't going to see him as some kind of object either. Quality destroys objectivity every time.” — Zen and the Art of Motorcycle Maintenance
  23. #DevoxxFR Software Testing With motorcycles, you drive to test them.

    With software, you can test it without driving it. Or rather, you can automate the driving. If you don’t automate tests, you’re still testing!
  24. #DevoxxFR What you learned How to… Build an Angular application

    with modern tools Unit test Angular services, mocking Http provider Unit test Angular components, mocking service Integration test an Angular application Continuously test and deploy with a CI server
  25. #DevoxxFR Lab: Test an Angular Project Unit testing Integration testing

    Continous Integration Deploy to the ☁! http://bit.ly/ng-test
  26. #DevoxxFR ng-book 2 A comprehensive guide to developing with Angular

    2 Sample apps: Reddit clone, Chat with RxJS Observables, YouTube search-as-you-type, Spotify Search How to write components, use forms and APIs Over 5,500+ lines of code!
  27. #DevoxxFR ng-book 2 A comprehensive guide to developing with Angular

    4 Worth all your hard earned $$$ https://www.ng-book.com/2 “Thank you for the awesome book, it's the bible for Angular.” — Vijay Ganta
  28. #DevoxxFR Testing Angular Applications Book Unit testing directives, pipes, services,

    and routes End-to-end testing with elements and forms 5 of 10 chapters available Estimated publication: Fall 2017 www.manning.com/books/testing-angular-applications
  29. #DevoxxFR Who’s using Angular? Made with AngularJS https://www.madewithangular.com Angular Expo

    http://angularexpo.com Awesome Angular https://github.com/AngularClass/awesome-angular
  30. #DevoxxFR Angular Performance Checklist Network performance Bundling Minification and Dead

    code elimination Ahead-of-Time (AoT) Compilation Compression Pre-fetching Resources Lazy-Loading of Resources Caching https://github.com/mgechev/angular-performance-checklist
  31. #DevoxxFR The JHipster Mini-Book 2.0 Release on Dec 5, 2016

    jhipster-book.com 21-points.com @jhipster_book Write your own InfoQ mini-book! github.com/mraible/infoq-mini-book