This is an example application for [Migrating Angular 1 Applications to Angular 2 in 5 Simple Steps] (https://vsavkin.com/migrating-angular-1-applications-to-angular-2-in-5-simple-steps-40621800a25b#.oj2pbb5de)
The application shows how to migrate an AngularJS app to Angular using the Angular router. It uses WebPack 2.0 and AoT compilation.
-
clone this repo
-
npm install
-
npm start
-
open
localhost:8080
-
optionally
npm run build
to build bundle
The application has three modules:
- Main Menu
- Messages
- Settings
They illustrate the three stages of migrating modules from Angular 1 to Angular 2.
- The Main Menu module is written in AngularJS. In other words, the migration of this module hasn't started yet.
- The Messages module is written using AngularJS, but one of its components has been migrated to Angular.
- The Settings module is written using Angular. In other words, the migration of this module has been completed.
Every module defines components, services, and routes. In addition every module has an NgModule with a static methods where we can downgrade/upgrade, components and services.
These are the routes the application supports:
- /
- /messages/:folder
- /messages/:folder/:id
- /settings
- /settings/pagesize
The first three routes are handled by the Angular 1 router, and the last two are handled by the Angular 2 router. We define a custom UrlHandlingStrategy to partition all URLs into these two sets.
See comments in ng2_app.ts
and main.ts
.