Slide 1

Slide 1 text

Upgrading to Angular 2 @mattdsteele https://steele.blue

Slide 2

Slide 2 text

Everything is terrible

Slide 3

Slide 3 text

Everything is terrible Your App

Slide 4

Slide 4 text

Upgrade Options

Slide 5

Slide 5 text

Upgrade Options

Slide 6

Slide 6 text

Upgrade Options Big Bang Rewrite

Slide 7

Slide 7 text

Upgrade Options Big Bang Rewrite ngForward

Slide 8

Slide 8 text

Upgrade Options Big Bang Rewrite ngForward ngUpgrade

Slide 9

Slide 9 text

Upgrade Options Big Bang Rewrite ngForward ngUpgrade

Slide 10

Slide 10 text

ngYourAppIsSaved

Slide 11

Slide 11 text

Angular 2 Module

Slide 12

Slide 12 text

Angular 2 Module import { UpgradeAdapter } from 'angular2/upgrade';

Slide 13

Slide 13 text

Run In Parallel

Slide 14

Slide 14 text

Component Interoperability

Slide 15

Slide 15 text

Component Interoperability In Both Directions*

Slide 16

Slide 16 text

What can be upgraded?

Slide 17

Slide 17 text

Components & Services

Slide 18

Slide 18 text

Angular 1 Components

Slide 19

Slide 19 text

Angular 1 Components Must Be:

Slide 20

Slide 20 text

Angular 1 Components restrict: 'E' Must Be:

Slide 21

Slide 21 text

Angular 1 Components restrict: 'E' scope: {}, Must Be:

Slide 22

Slide 22 text

Angular 1 Components restrict: 'E' scope: {}, bindToController: {}, Must Be:

Slide 23

Slide 23 text

Angular 1 Components restrict: 'E' scope: {}, bindToController: {}, controllerAs, Must Be:

Slide 24

Slide 24 text

Angular 1 Components restrict: 'E' scope: {}, bindToController: {}, controllerAs, template Must Be:

Slide 25

Slide 25 text

Angular 1 Components Can Be:

Slide 26

Slide 26 text

Angular 1 Components Can Be: transclude: true,

Slide 27

Slide 27 text

Angular 1 Components Can Be: transclude: true, require

Slide 28

Slide 28 text

Angular 1 Components Must Not Be: compile replace: true priority terminal

Slide 29

Slide 29 text

.component()

Slide 30

Slide 30 text

Angular 1 Services

Slide 31

Slide 31 text

Angular 1 Services Pretty Straightforward

Slide 32

Slide 32 text

Angular 2 Components

Slide 33

Slide 33 text

Angular 2 Services

Slide 34

Slide 34 text

Transclusion/Content Projection

Slide 35

Slide 35 text

Transclusion/Content Projection

Slide 36

Slide 36 text

Transclusion/Content Projection

Slide 37

Slide 37 text

Component Tree

Slide 38

Slide 38 text

Component Tree

Slide 39

Slide 39 text

angular.io/docs/ts/latest/guide/upgrade.html

Slide 40

Slide 40 text

Upgrade Strategy

Slide 41

Slide 41 text

Stuff You Can Do Now

Slide 42

Slide 42 text

Stuff You Can Do Now • Code in TypeScript/ES6

Slide 43

Slide 43 text

Stuff You Can Do Now • Code in TypeScript/ES6 • Use a module loader

Slide 44

Slide 44 text

Stuff You Can Do Now • Code in TypeScript/ES6 • Use a module loader • Convert factories/services/providers to Services (ES6 Classes)

Slide 45

Slide 45 text

Stuff You Can Do Now • Code in TypeScript/ES6 • Use a module loader • Convert factories/services/providers to Services (ES6 Classes) • Convert Directives to Components

Slide 46

Slide 46 text

Upgrade Time

Slide 47

Slide 47 text

Upgrade Time • Launch as hybrid app (UpgradeAdapter)

Slide 48

Slide 48 text

Upgrade Time • Launch as hybrid app (UpgradeAdapter) • Migrate components

Slide 49

Slide 49 text

In The Future

Slide 50

Slide 50 text

In The Future Drop ng1

Slide 51

Slide 51 text

In The Future Drop ng1 Bask in glory

Slide 52

Slide 52 text

Let's Upgrade Something

Slide 53

Slide 53 text

Super Bowl Squares http://www.zpoolz.com/main/Poolz_Football/2015/2016sbs5.jpg

Slide 54

Slide 54 text

Services Datasets Data

Slide 55

Slide 55 text

square-cell Components superbowl-header superbowl-squares square-cell square-cell

Slide 56

Slide 56 text

square-cell Components + Services superbowl-header superbowl-squares square-cell square-cell Datasets Data

Slide 57

Slide 57 text

square-cell Angular 1 Components superbowl-header superbowl-squares square-cell square-cell Datasets Data

Slide 58

Slide 58 text

square-cell 1. Boot with UpgradeAdapter superbowl-header superbowl-squares square-cell square-cell Datasets Data UpgradeAdapter

Slide 59

Slide 59 text

square-cell 2. Services superbowl-header superbowl-squares square-cell square-cell Datasets Data UpgradeAdapter

Slide 60

Slide 60 text

square-cell 3. Add Top Level App superbowl-header superbowl-squares square-cell square-cell Datasets Data UpgradeAdapter superbowl-app

Slide 61

Slide 61 text

square-cell 4. Header Component superbowl-header superbowl-squares square-cell square-cell Datasets Data UpgradeAdapter superbowl-app

Slide 62

Slide 62 text

square-cell 5. App superbowl-header superbowl-squares square-cell square-cell Datasets Data UpgradeAdapter superbowl-app

Slide 63

Slide 63 text

square-cell 6. Cells superbowl-header superbowl-squares square-cell square-cell Datasets Data UpgradeAdapter superbowl-app

Slide 64

Slide 64 text

square-cell 7. Squares superbowl-header superbowl-squares square-cell square-cell Datasets Data UpgradeAdapter superbowl-app

Slide 65

Slide 65 text

square-cell 8. Bootstrap with ng2 superbowl-header superbowl-squares square-cell square-cell Datasets Data superbowl-app

Slide 66

Slide 66 text

Gotchas

Slide 67

Slide 67 text

Testing

Slide 68

Slide 68 text

Testing • Testing w/o Angular? Easy

Slide 69

Slide 69 text

Testing • Testing w/o Angular? Easy • Good recipes for ng2 tests
 https://medium.com/google-developer-experts/angular-2-unit- testing-with-jasmine-defe20421584#.pevppwgy2
 https://speakerdeck.com/cironunes/unit-testing-in-angular-2

Slide 70

Slide 70 text

End To End Tests

Slide 71

Slide 71 text

Testing Hybrid Components superbowl-squares Datasets Data http://stackoverflow.com/questions/36827715/testing-an-angular-app-with- ngupgrade-fails-with-unknown-provider-ng2-injector

Slide 72

Slide 72 text

Testing Hybrid Components https://github.com/mattdsteele/football-squares/commit/ 77c1d42d4ef5e1546f1de46efa56db4caff232f7 superbowl-header superbowl-squares Datasets Data superbowl-app

Slide 73

Slide 73 text

Template Syntax square-cell superbowl-squares square-cell square-cell

Slide 74

Slide 74 text

Template Syntax square-cell superbowl-squares square-cell square-cell

Slide 75

Slide 75 text

Template Syntax square-cell superbowl-squares square-cell square-cell

Slide 76

Slide 76 text

Bookmark These Sites • http://angularjs.blogspot.com/2015/08/angular-1-and-angular-2-coexistence.html • https://angular.io/docs/ts/latest/guide/upgrade.html • http://blog.thoughtram.io/angular/2015/10/24/upgrading-apps-to-angular-2-using-ngupgrade.html • http://teropa.info/blog/2015/10/18/refactoring-angular-apps-to-components.html

Slide 77

Slide 77 text

/mattdsteele/football-squares @mattdsteele https://steele.blue

Slide 78

Slide 78 text

Routing • Component Router • UI Router • http://slides.com/christhielen/ui-router-ng1-to-ng2 • https://youtu.be/mnkG-RRkZtU