@ChrisThielen
Migrating a UI-Router application to Angular 2
Slides URL: http://bit.ly/UIR-ngMN-slides
The defacto standard for routing in Angular 1
Currently in beta
Currently in alpha
Now Later Finally
➤ Migration Plan
$stateChangeStart
$stateChangeSuccess
$stateChangeError
onBefore (sync)
onStart
onExit (for a state)
onRetain (for a state)
onEnter (for a state)
onFinish
onSuccess/onError
➤ Update UI-Router
Follow along:
http://bit.ly/UIR-sample
http://bit.ly/ngMN-sample
➤ Update UI-Router
➤ Update UI-Router
➤ Update UI-Router
➤ Update UI-Router
.component() api
helpful blog post: http://bit.ly/component15
➤ Migrate to .component()
➤ Migrate to .component()
.state("foo", {
template: "<component foo-binding='$resolve.foo'></component>"
});➤ Migrate to .component()
➤ Migrate to .component()
➤ Migrate to .component()
Write modular code. Import dependent code.
ES6 and Typescript: import {fooComp} from "./foo"
CommonJS: var fooComp = require("./foo").fooComp
➤ Add Angular 2
Module Loader. Bundler.
Each of these tools can follow the application dependency tree from the root of your application
➤ Add Angular 2
$ npm install➤ Add Angular 2
Use <script> tags. Order exactly as shown
➤ Add Angular 2
Wire up angular2/upgrade and ui-router-ng1-to-ng2
➤ Add Angular 2
➤ ng2 components
ng1
ng2
➤ ng2 components
➤ Cleanup
Now Later Finally
Start here: https://github.com/ui-router/quickstart-ng2
➤ Big Bang
Component Doc: https://docs.angularjs.org/guide/component
1.3+ Polyfill: https://github.com/toddmotto/angular-component
UI-Router: https://github.com/angular-ui/ui-router/releases
UI-Router Sample App: https://github.com/ui-router/sample-app
UI-Router ng2 adapter: https://github.com/ui-router/ng1-to-ng2
UIR ng2 quickstart: https://github.com/ui-router/quickstart-ng2
http://teropa.info/blog/2015/10/18/refactoring-angular-apps-to-components.html - or- http://bit.ly/component15
Official upgrade docs for ng2:
https://angular.io/docs/ts/latest/guide/upgrade.html