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

Building Universal Applications with Angular 2

Minko Gechev
November 07, 2015

Building Universal Applications with Angular 2

Angular is one of the most popular frameworks for the development of Single-Page Applications (SPA). Recently Google announced its second major version, which brings some brand new ideas and improvements. For instance, Angular 2 is written in TypeScript, has much faster change detection and allows development of universal (isomorphic) applications.

In this talk we're going to introduce the motivation behind the new design decisions and the improvements in Angular 2. We'll take a look at the building blocks the framework provides for the development of professional single-page applications.

Minko Gechev

November 07, 2015
Tweet

More Decks by Minko Gechev

Other Decks in Programming

Transcript

  1. Agenda What is Angular? What’s wrong with Angular 2? Introduction

    to Angular 2 Why Angular 2 is awesome? Should I use Angular 2 in my next project?
  2. Agenda What is Angular 2? What’s wrong with Angular 2?

    What are the core concepts of Angular 2? Why Angular 2 is awesome? Should I use Angular 2 in my next project?
  3. Agenda What is Angular 2? What’s wrong with Angular 2?

    What are the core concepts of Angular 2? Why Angular 2 is awesome? Should I use Angular 2 in my next project?
  4. Agenda What is Angular 2? What’s wrong with Angular 2?

    What are the core concepts of Angular 2? Why Angular 2 is awesome? Should I use Angular 2 in my next project?
  5. Agenda What is Angular 2? What’s wrong with Angular 2?

    What are the core concepts of Angular 2? Why Angular 2 is awesome? Should I use Angular 2 in my next project?
  6. Agenda What is Angular 2? What’s wrong with Angular 2?

    What are the core concepts of Angular 2? Why Angular 2 is awesome? Should I use Angular 2 in my next project?
  7. Core concepts of Angular 2 • Directives • Components •

    Pipes • Services • Dependency Injection
  8. tooltip.ts @Directive({ selector: '[tooltip]', inputs: ['tooltip'], host: { '(mouseenter)': 'onMouseEnter()',

    '(mouseleave)': 'onMouseLeave()' } }) export class Tooltip { private overlay:Overlay; private tooltip:string; constructor(private el:ElementRef, manager: OverlayManager) { this.el = el; this.overlay = manager.get(); } onMouseEnter() { this.overlay.open(this.el, this.tooltip); } onMouseLeave() { this.overlay.close(); } }
  9. tooltip.ts @Directive({ selector: '[tooltip]', inputs: ['tooltip'], host: { '(mouseenter)': 'onMouseEnter()',

    '(mouseleave)': 'onMouseLeave()' } }) export class Tooltip { private overlay:Overlay; private tooltip:string; constructor(private el:ElementRef, manager: OverlayManager) { this.el = el; this.overlay = manager.get(); } onMouseEnter() { this.overlay.open(this.el, this.tooltip); } onMouseLeave() { this.overlay.close(); } }
  10. tooltip.ts @Directive({ selector: '[tooltip]', inputs: ['tooltip'], host: { '(mouseenter)': 'onMouseEnter()',

    '(mouseleave)': 'onMouseLeave()' } }) export class Tooltip { private overlay:Overlay; private tooltip:string; constructor(private el:ElementRef, manager: OverlayManager) { this.el = el; this.overlay = manager.get(); } onMouseEnter() { this.overlay.open(this.el, this.tooltip); } onMouseLeave() { this.overlay.close(); } }
  11. tooltip.js var Tooltip = ng.Directive({ selector: '[tooltip]', inputs: ['tooltip'], host:

    { '(mouseenter)': 'onMouseEnter()', '(mouseleave)': 'onMouseLeave()' } }) .Class({ constructor: [ng.Inject(ng.ElementRef), ng.Inject(OverlayManager), function (tooltip, el, manager) { this.el = el; this.overlay = manager.get(tooltip); }], onMouseEnter() { this.overlay.open(this.el, this.tooltip); }, onMouseLeave() { this.overlay.close(); } });
  12. tooltip.js var Tooltip = ng.Directive({ selector: '[tooltip]', inputs: ['tooltip'], host:

    { '(mouseenter)': 'onMouseEnter()', '(mouseleave)': 'onMouseLeave()' } }) .Class({ constructor: [ng.Inject(ng.ElementRef), ng.Inject(OverlayManager), function (tooltip, el, manager) { this.el = el; this.overlay = manager.get(tooltip); }], onMouseEnter() { this.overlay.open(this.el, this.tooltip); }, onMouseLeave() { this.overlay.close(); } });
  13. tooltip.js var Tooltip = ng.Directive({ selector: '[tooltip]', inputs: ['tooltip'], host:

    { '(mouseenter)': 'onMouseEnter()', '(mouseleave)': 'onMouseLeave()' } }) .Class({ constructor: [ng.Inject(ng.ElementRef), ng.Inject(OverlayManager), function (tooltip, el, manager) { this.el = el; this.overlay = manager.get(tooltip); }], onMouseEnter() { this.overlay.open(this.el, this.tooltip); }, onMouseLeave() { this.overlay.close(); } });
  14. lowercase-pipe.ts @Pipe({ name: 'lowercase' }) class LowerCasePipe implements PipeTransform {

    transform(value: string): string { if (!value) return value; if (typeof value !== 'string') { throw new Error('Invalid pipe value', value); } return value.toLowerCase(); } }
  15. di.ts import { provide, Injector, Injectable } from 'angular2/angular2'; class

    Http {} @Injectable() class DataMapper { constructor(private http: Http) {} } let injector = Injector.resolveAndCreate([ provide(Http, { useValue: new Http() }), DataMapper ]); injector.get(DataMapper);
  16. di.ts import { provide, Injector, Injectable } from 'angular2/angular2'; class

    Http {} @Injectable() class DataMapper { constructor(private http: Http) {} } let injector = Injector.resolveAndCreate([ provide(Http, { useValue: new Http() }), DataMapper ]); injector.get(DataMapper);
  17. di.ts import { provide, Injector, Injectable } from 'angular2/angular2'; class

    Http {} @Injectable() class DataMapper { constructor(private http: Http) {} } let injector = Injector.resolveAndCreate([ provide(Http, { useValue: new Http() }), DataMapper ]); injector.get(DataMapper);
  18. di.ts import { provide, Injector, Injectable } from 'angular2/angular2'; class

    Http {} @Injectable() class DataMapper { constructor(private http: Http) {} } let injector = Injector.resolveAndCreate([ provide(Http, { useValue: new Http() }), DataMapper ]); injector.get(DataMapper);