Giter Club home page Giter Club logo

ng1ng2router's Introduction

Migrating AngularJS Applications to Angular Using NgUpgrade and Angular Router

Article

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.

How to Run

  • clone this repo

  • npm install

  • npm start

  • open localhost:8080

  • optionally npm run build to build bundle

Application

Modules

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.

Routes

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.

Wiring it Up

See comments in ng2_app.ts and main.ts.

ng1ng2router's People

Contributors

vsavkin avatar vicb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.