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

Introduction to Angular 2

Introduction to Angular 2

Besides the progressive growing of Web Applications in the last few years, the new version of this super framework give us awesome new things. Change detection? Syntax sugar? ES6? Native APIs?

Avatar for Dhyego Fernando

Dhyego Fernando

April 09, 2016
Tweet

More Decks by Dhyego Fernando

Other Decks in Technology

Transcript

  1. Introduction to Angular 2, DevMT Meetup, April 2016 Agenda ✓

    How to prepare yourself? ✓ Short history about SPA ✓ Why Angular 2?
  2. Introduction to Angular 2, DevMT Meetup, April 2016 Data-binding <input

    type="text" ng-model="yourName"> <h1>Hello {{yourName}}!</h1>
  3. Introduction to Angular 2, DevMT Meetup, April 2016 Directives <tabset>

    <tab heading="Title 1"> <p>Content 1 goes here</p> </tab> <tab heading="Title 2"> <p>Content 2 goes here</p> </tab> <tab heading="Title 3"> <p>Content 3 goes here</p> </tab> </tabset>
  4. Introduction to Angular 2, DevMT Meetup, April 2016 AngularJS (1.x)

    → Design decisions (not so good) → Web platform evolution More at http://blog.jhades.org/introduction-to-angular2-the-main-goals
  5. Introduction to Angular 2, DevMT Meetup, April 2016 Design Decisions

    → Third-party libraries (interoperability) → Directive Definition Object → $scope and $digest cycles
  6. Introduction to Angular 2, DevMT Meetup, April 2016 Web platform

    evolution → Web Workers → Web Components → ES6, ES7, TypeScript, Dart… → Offline Apps (Service Workers) → Mobile Apps
  7. Introduction to Angular 2, DevMT Meetup, April 2016 What’s new?

    Edge Web API Template Syntax Change Detection
  8. Introduction to Angular 2, DevMT Meetup, April 2016 Edge Web

    API x Directives + Content Transclusion ✓ Directives + Content Transclusion ✓ Components + Content Projection
  9. Introduction to Angular 2, DevMT Meetup, April 2016 Angular 1:

    Directives + Content Transclusion My Title My Content Property binding Content transclusion <my-card title="My Title"> <p>My Content</p> </my-card>
  10. Introduction to Angular 2, DevMT Meetup, April 2016 Property binding

    Content transclusion Angular 1: Directives + Content Transclusion app.directive('myCard', function() { // ... scope: { title: '@' }, transclude: true });
  11. Introduction to Angular 2, DevMT Meetup, April 2016 Property binding

    Content transclusion <div class="my-card"> <h1>{{ title }}</h1> <div ng-transclude></div> </div> Angular 1: Directives + Content Transclusion
  12. Introduction to Angular 2, DevMT Meetup, April 2016 Angular 2:

    Components + Content Projection Property binding Content transclusion <my-card [title]=“‘My Title’"> <p>My Content</p> </my-card>
  13. Introduction to Angular 2, DevMT Meetup, April 2016 Property binding

    Content transclusion Angular 2: Components + Content Projection <div class="my-card"> <h1>{{ title }}</h1> <content></content> </div>
  14. Introduction to Angular 2, DevMT Meetup, April 2016 Property binding

    Content transclusion Angular 2: Components + Content Projection @Component({ selector: 'my-card', properties: ['title'] }) @View({ // ... encapsulation: ViewEncapsulation.Native }) class MyCard { }
  15. Introduction to Angular 2, DevMT Meetup, April 2016 Edge Web

    API ✓ Component encapsulation (emulated or native) ✓ Plain JS Classes + Metadata
 (TypeScript decorators are optionals)
  16. Introduction to Angular 2, DevMT Meetup, April 2016 Angular 1:

    Template syntax Entry property Entry property Out property <my-card title="{{ title }}" visible="visible" remove="onRemove()"></my-card> scope: { title: '@', visible: '=', on-remote: '&' }
  17. Introduction to Angular 2, DevMT Meetup, April 2016 Templates Binding

    Example Properties Events Two-way https://angular.io/docs/ts/latest/guide/template-syntax.html#!#binding-syntax <input [value]="firstName"> <button (click)="save($event)"> <input [(ng-model)]="firstName">
  18. Introduction to Angular 2, DevMT Meetup, April 2016 Angular 2:

    Template syntax Entry property Entry property Out property properties: [ 'title', 'visible' ] @Output() remove = new EventEmitter(); <my-card [title]=“title" [visible]=“visible” (remove)=“onRemove()”></my-card>
  19. Introduction to Angular 2, DevMT Meetup, April 2016 Template Syntax

    ✓ Simpler API to memorize ✓ Valid HTML ✓ Syntax more semantic
  20. Introduction to Angular 2, DevMT Meetup, April 2016 Change Detection

    ✓ Cyclic graphs x Cyclic graphs ✓ Tree of components
  21. Introduction to Angular 2, DevMT Meetup, April 2016 Angular 1:

    Cyclic graphs x Dirty checking x Unpredictable watchers x Unpredictable digest cycle runs http://blog.jhades.org/introduction-to-angular2-the-main-goals/#howangular1implementsbinding
  22. Introduction to Angular 2, DevMT Meetup, April 2016 Angular 2:

    Tree of components ✓ Predictable watchers ✓ Independent change detector ✓ Switchable strategies for each CD
 (great for immutability) @Component({ changeDetection: ChangeDetectionStrategy.OnPush }) http://victorsavkin.com/post/110170125256/change-detection-in-angular-2
  23. Introduction to Angular 2, DevMT Meetup, April 2016 Change Detection

    ✓ Faster changes detections (3x ~ 5x) ✓ Independent component CD ✓ Switchable change strategies
 (can be more faster yet 3x ~ 8x) ✓ Tree of components
  24. Introduction to Angular 2, DevMT Meetup, April 2016 Web Workers

    Support ✓ Sandbox untrusted code ✓ Awesome for mobile ✓ Concurrency & Parallelism https://github.com/angular/angular/blob/master/modules/angular2/docs/web_workers/web_workers.md
  25. Introduction to Angular 2, DevMT Meetup, April 2016 Unidirectional Data

    Flow ✓ Easier to debug ✓ Interoperable (RxJS, Flux, Redux…) ✓ Faster
  26. Introduction to Angular 2, DevMT Meetup, April 2016 ES5 ES6

    TypeScript Dart Multi Languages Support
  27. Introduction to Angular 2, DevMT Meetup, April 2016 ES5 ES6

    TypeScript Dart No Compile Compile Multi Languages Support
  28. Introduction to Angular 2, DevMT Meetup, April 2016 ES5 ES6

    TypeScript Dart No Types Types Multi Languages Support
  29. Introduction to Angular 2, DevMT Meetup, April 2016 ES5 ES6

    TypeScript Dart JavaScript-Based Syntax No JS Multi Languages Support
  30. Introduction to Angular 2, DevMT Meetup, April 2016 ES6 ES5

    TypeScript Dart No JS ES6 JavaScript-Based Syntax Multi Languages Support
  31. Introduction to Angular 2, DevMT Meetup, April 2016 TypeScript ES6

    ES5 Dart No JS TypeScript ES6 JavaScript-Based Syntax Multi Languages Support
  32. Introduction to Angular 2, DevMT Meetup, April 2016 Batarangle ✓

    Template navigation ✓ Debugging ✓ Performance analysis http://go.rangle.io/batarangle
  33. Introduction to Angular 2, DevMT Meetup, April 2016 Ionic Framework

    ✓ Apps featured by Google & Apple ✓ Battle-tested by lots of startups ✓ 1.2M+ apps built since 02/2014
  34. Introduction to Angular 2, DevMT Meetup, April 2016 Ionic v2

    built upon Angular 2 ✓ Use modern Web APIs like Web Workers ✓ Express Ionic as a more traditional GUI architecture ✓ Dramatically improve render performance ✓ Reduce the barrier to entry (it’s mostly vanilla javascript) http://ionic.io/2
  35. Introduction to Angular 2, DevMT Meetup, April 2016 New features

    ✓ Material design support ✓ New animation and scrolling ✓ Overhauled navigation ✓ Powerful theming system ✓ New components and templates
  36. Introduction to Angular 2, DevMT Meetup, April 2016 ngUpgrade Left

    Top Nav Main View 1 1 1 1 1 1 1 1 1 1 1 1 1
  37. Introduction to Angular 2, DevMT Meetup, April 2016 ngUpgrade Left

    Top Nav Main View 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2
  38. Introduction to Angular 2, DevMT Meetup, April 2016 Release Status

    https://splintercode.github.io/is-angular-2-ready/
  39. Introduction to Angular 2, DevMT Meetup, April 2016 Live Demo

    https://github.com/johnpapa/angular2-tour-of-heroes
  40. Introduction to Angular 2, DevMT Meetup, April 2016 Want to

    talk too? http://devmt.herokuapp.com/ +