We speak in hours, not days. Small changes and fixes ship the same day; first builds in weeks, not quarters.

Message us
AngularLegacy modernisationFrontendMigration

AngularJS to Angular migration: a step-by-step plan

How to migrate from AngularJS to Angular step by step: audit, ngUpgrade hybrid or rewrite, routing, testing, cutover and pitfalls that stall migrations.

WeBuildStack engineering team 15 min read

To migrate from AngularJS to Angular, audit the 1.x application, refactor it to components and TypeScript, bootstrap a hybrid app with ngUpgrade, convert services and components leaf-first, move routing, then remove AngularJS. Rewrite instead when the app is small or being redesigned. WeBuildStack is a software development company that builds web and mobile applications and the cloud they run on.

AngularJS reached the end of its road when Google discontinued long-term support on 31 December 2021. Several years on, a surprising number of business applications still run on it: internal portals, insurance back-offices, logistics dashboards and admin consoles that were built well, worked, and never justified a rewrite. We take on these migrations through our Angular practice, and the question is always the same: how do we get to a supported framework without stopping the business for six months?

The plan below is incremental by default, keeps the product shippable at every step, and is honest about the point where a clean rewrite is cheaper than a migration.

AngularJS to Angular migration step by step: the checklist

Each item links to the detailed section below. Work through them in order; the product stays live after every one.

  1. Decide: hybrid migration or rewrite. Large, busy, still-changing apps go hybrid; small or soon-to-be-redesigned apps are rewritten. Write the decision down. Step 0
  2. Inventory the codebase. Count controllers, directives, components, services, filters, routes, third-party directives and tests, and rank the modules by value and difficulty. Step 1
  3. Upgrade to AngularJS 1.8 in small releases, and arrange extended support for the duration. Step 2
  4. Refactor to the component style. $scope controllers become .component() definitions with one-way bindings and controllerAs. Step 2
  5. Move to ES modules, TypeScript and the Angular CLI build, still shipping AngularJS. Step 2
  6. Cover the critical paths with end-to-end tests on Playwright or Cypress before Angular appears. Step 6
  7. Bootstrap the hybrid app with ngUpgrade. Angular starts first and boots AngularJS through UpgradeModule; ship it as “same product, new bootstrap”. Step 3
  8. Convert leaf-first. Services, then leaf components, then containers, then filters to pipes, each downgraded so the old code keeps working. New features are written in Angular only. Step 4
  9. Move routing with the ui-router hybrid package, or switch to the Angular Router in one tested release. Step 5
  10. Cut over. Remove UpgradeModule and every AngularJS package in one release, with the previous build ready to redeploy. Step 7

The steps at a glance: what you do and when each is done

Step What you do Done when
0. Decide Hybrid migration or rewrite, from the audit numbers The decision and its reasons are written down
1. Inventory Count components, scope controllers, directives, routes, tests A ranked backlog of modules exists
2. Prepare Component style, ES modules, TypeScript, Angular CLI build The AngularJS app ships from the new build
3. Hybrid bootstrap Angular boots first and runs AngularJS through UpgradeModule The same product is live on the new bootstrap
4. Leaf-first migration Services, leaf components, containers, filters to pipes The AngularJS component count falls every week
5. Routing ui-router hybrid, or one tested switch to the Angular Router Every route, redirect and deep link passes
6. Testing End-to-end suite on Playwright or Cypress, unit tests move with the code Both suites green in CI throughout
7. Cutover Remove the bridge and every AngularJS package in one release One framework, a smaller bundle, a rollback plan unused

Why migrate from AngularJS to Angular now

Three forces push the decision, in roughly this order of urgency.

Security. The AngularJS package on npm is deprecated and receives no fixes from the framework team. Vulnerabilities reported since 2022 stay open in the public builds, and your dependency scanner will keep flagging them. Paid extended support from vendors such as XLTS.dev exists, and we recommend it as a bridge while you migrate, not as a destination.

Toolchain drift. AngularJS predates ES modules, TypeScript as a default, and the current generation of bundlers. Every year, a few more of the libraries, build tools and browser features your team wants will not work cleanly with it. The cost shows up as days lost to compatibility hacks rather than one big failure.

Hiring. Engineers who want to work on AngularJS are increasingly hard to find, and the ones you have would rather not. A migration is as much a retention decision as a technical one.

Step 0: hybrid migration or rewrite?

Before the plan, the fork. The hybrid migration described below is designed for applications that are large, in daily use, and still changing. For those, running both frameworks side by side is the only way to keep shipping. But it carries overhead: two frameworks in the bundle, two mental models in code review, and a bridge layer to maintain until the end.

Factor Favours a hybrid ngUpgrade migration Favours a rewrite
Size Hundreds of components and screens Small enough to rebuild in a handful of sprints
Change rate Features ship every sprint and cannot pause The app is stable or about to be redesigned
Code shape Mostly .component() with one-way bindings $scope inheritance, jQuery DOM work, global state
Tests Some end-to-end coverage of critical paths None, and little appetite to add it to old code
Templates The UI stays as it is The UI is being redesigned, so templates would not survive

We make this decision at the end of step 1, with numbers. It is the single most consequential choice in the whole programme, and it should be written down with its reasoning. If the team is also weighing a different framework altogether, our React vs Angular comparison covers that fork.

Step 1: inventory the AngularJS codebase

A migration estimate without an audit is a guess. Ours takes a tech lead a few days on a mid-sized application and produces a one-page report. What we inventory:

  • Version and shape. AngularJS 1.8 is the final release; anything earlier needs an upgrade first, inside the old framework, because the hybrid bridge targets the 1.5+ component API. Count controllers, directives, components, services, filters and routes.
  • Component readiness. How much of the UI already uses .component() with one-way bindings and controllerAs, and how much is $scope-bound controllers and link-function directives. This ratio, more than line count, predicts effort.
  • Third-party directives. Date pickers, grids, charts and modals written for AngularJS have no Angular equivalent that drops in. Each one becomes a decision: wrap it, replace it, or rebuild it.
  • Routing. ngRoute, ui-router, or custom. ui-router has a supported hybrid path; the others need more care.
  • Build and module system. Script tags and globals, Browserify, webpack, or a gulp pipeline that nobody dares touch. The migration will replace this with the Angular CLI, and the earlier it happens the better.
  • HTTP and auth. $http interceptors that add tokens, retry or redirect on 401. Angular’s HttpClient needs its own interceptors, and during the hybrid phase both must behave identically.
  • Tests. Karma and Jasmine coverage, Protractor end-to-end suites (Protractor itself is retired), and what actually runs in CI today.
  • Shared state. $rootScope events, service singletons used as global stores, and anything reaching into the DOM.

A quick way to get the first numbers is a search across the source: count .controller(, .directive(, .component(, .service(, .factory( and $scope references per module. The output is a table of modules ranked by business value and migration difficulty. That table is the backlog for everything that follows.

Step 2: prepare the AngularJS application

The best migration work happens before Angular appears. These steps improve the old application on their own, and each one makes the hybrid phase cheaper. The Angular team’s own upgrade guide describes them as preparation, and we treat them as a release in their own right.

  1. Upgrade to AngularJS 1.8. Work through the breaking changes between your version and 1.8 first, in small releases, so the hybrid bridge has the API it expects.
  2. Follow the component style. Convert $scope controllers to .component() definitions with one-way bindings and controllerAs. This is the single highest-leverage change: an AngularJS component maps almost one-to-one onto an Angular component, while a scope-bound controller maps onto nothing.
  3. One file per unit, ES modules. Split monolithic files so that each component, service or filter is a module that imports its dependencies. This makes the later TypeScript conversion and lazy loading possible.
  4. Introduce TypeScript. Rename files to .ts, start with any where needed, and tighten over time. Type definitions for AngularJS exist on DefinitelyTyped, so the compiler can help even before Angular arrives.
  5. Adopt a modern build. Move the build onto the Angular CLI’s toolchain as early as possible, even while the app is still AngularJS. One pipeline for both frameworks removes a whole class of integration problems.
  6. Remove DOM manipulation from controllers. Anything using jQuery or direct DOM access inside business logic has to move into directives or, better, disappear.
  7. Cover the critical paths with tests. Not everything; the flows that make money or that break silently. End-to-end tests written against the real UI survive the migration and tell you when a converted view has regressed.

Teams sometimes resist spending budget on “the old app”. The reframe that works: this is the first third of the migration, done in a form that ships value every sprint.

Step 3: bootstrap the hybrid app with ngUpgrade

Angular’s @angular/upgrade package provides UpgradeModule, which runs an AngularJS application inside an Angular one. The Angular app bootstraps first, then bootstraps AngularJS on the same root element, and the two frameworks share a dependency-injection boundary and run change detection in step.

// app.module.ts: Angular starts first, then hands the page to AngularJS
import { DoBootstrap, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { UpgradeModule } from '@angular/upgrade/static';

@NgModule({ imports: [BrowserModule, UpgradeModule] })
export class AppModule implements DoBootstrap {
  constructor(private upgrade: UpgradeModule) {}
  ngDoBootstrap() {
    this.upgrade.bootstrap(document.body, ['legacyApp'], { strictDi: true });
  }
}

// main.ts
platformBrowserDynamic().bootstrapModule(AppModule);

The mechanics, in order:

  • Create a fresh Angular workspace with the CLI and move the AngularJS source into it, so both live in one repository with one build.
  • Remove ng-app from index.html; the Angular module above now starts AngularJS.
  • Verify the application behaves exactly as before. Nothing has been migrated yet; this release is “same product, new bootstrap”. Ship it.

UpgradeModule needs an NgModule at the root and zone.js, so keep both until the bridge is gone; standalone components are fine for the new code inside it, and the root can follow after cutover. For very large apps where running both frameworks’ change detection on every event is too slow, downgradeModule is the alternative: AngularJS stays in charge and Angular boots lazily the first time one of its components appears. It keeps the two change-detection systems apart, which is faster, but some cross-framework updates then need an explicit trigger.

A note on bundle size: during the hybrid phase you ship both frameworks. Lazy-load the Angular feature areas as they appear so the extra cost is paid only where it is used, and set a budget in the CLI configuration so regressions are caught in CI.

Step 4: migrate AngularJS to Angular leaf-first

The order matters. Convert things with the fewest dependants first, so that each converted piece is used by code that does not yet need to change. The bridge works in both directions:

// Angular code made available to AngularJS
import { downgradeComponent, downgradeInjectable } from '@angular/upgrade/static';

angular.module('legacyApp')
  .factory('pricingService', downgradeInjectable(PricingService))
  .directive('appOrderSummary', downgradeComponent({ component: OrderSummaryComponent }));

// An AngularJS service made available to Angular, until it is converted
export const legacyAuthProvider = {
  provide: LegacyAuth,
  useFactory: (i: any) => i.get('authService'),
  deps: ['$injector'],
};
  1. Services first. Pure services (API clients, formatters, validation) convert to injectable Angular classes with little ceremony. Downgrade each one with downgradeInjectable so existing AngularJS code keeps working, and expose the AngularJS services not yet converted to Angular through $injector providers like the one above.
  2. Leaf components next. Presentational components with inputs and outputs and no children are the easiest conversions. Downgrade each one with downgradeComponent so its existing AngularJS parent keeps rendering it with the kebab-case element name and Angular binding syntax (<app-order-summary [order]="$ctrl.order">).
  3. Then container components, walking up the tree. Each converted container brings its already-converted children into the Angular world and removes a bridge. Where a container needs an AngularJS child that is not converted yet, wrap the child with UpgradeComponent rather than converting it out of order.
  4. Filters become pipes, usually mechanically.
  5. Third-party directives are handled by the decision made in the audit: wrap behind an Angular component, replace with an Angular-native library, or rebuild.

New features during this period are written in Angular only. That is a rule, not a preference: it stops the AngularJS surface growing while you are shrinking it. Modern Angular makes this pleasant; standalone components are the default and signals give a reactivity model that is simpler to reason about than $scope digests ever were, so new code written now will not need a second migration later.

For very large applications there is a variant worth knowing: instead of upgrading Angular components into AngularJS, package new Angular features as Angular elements (custom elements) and drop them into the old templates. This removes the tight coupling of the shared injector at the cost of a clearer boundary, and it suits teams that want the two codebases to evolve independently until the switch-over. This is the strangler fig pattern applied to a front end.

Step 5: routing

Routing is where hybrid migrations stall, because both frameworks want to own the URL.

If the application uses ui-router, the maintainers provide @uirouter/angular-hybrid, which lets ui-router manage states that render either AngularJS or Angular views. This is the smoothest path: routing stays as it is, and views switch framework one at a time.

If the application uses ngRoute, the usual approach is to keep ngRoute in charge during the hybrid phase and introduce the Angular Router only once a majority of views are Angular, at which point you switch in one release. If the two routers must coexist for a while, Angular’s setUpLocationSync (from @angular/router/upgrade) keeps the Angular Router in step with AngularJS $location changes; without it you get the subtle bugs (double navigation, lost query parameters, broken back button) that erode trust in the migration.

Either way, treat the final router switch as its own milestone with its own regression pass over every route, redirect, guard and deep link, including the links in your emails and notifications.

Step 6: testing throughout

The hybrid phase is exactly when regressions slip in, so the test strategy has to be settled before step 3.

  • End-to-end tests are the safety net. Protractor is retired, so move the critical-path suite to Playwright or Cypress during preparation; those tests do not care which framework rendered the page and will outlive the migration.
  • Unit tests travel with the code. Karma is deprecated by the Angular team; new Angular tests should target the CLI’s current test runner so the unit suite is not migrated twice. Keep the old Jasmine suite running for untouched AngularJS code until that code is gone.
  • Visual checks on the converted screens catch the styling differences that come from leaving AngularJS’s class and attribute conventions behind.

Keep both suites green in CI for the whole programme. A migration that disables tests “temporarily” is a rewrite in disguise.

Step 7: cutover and removing AngularJS

In an incremental migration the cutover is small by design: most of the product has already shipped on Angular, release by release. The last release removes the bridge.

  • Remove UpgradeModule, the AngularJS bootstrap, and every downgrade and $injector registration.
  • Remove angular, angular-* and the hybrid router packages from package.json.
  • Delete the AngularJS test configuration.
  • Move the root to standalone bootstrapping if you want to, and consider zoneless change detection now that nothing depends on zone.js for the bridge.
  • Re-measure the bundle; the drop is usually large and is a good number to report to whoever funded the work.
  • Run the CLI’s update guide to bring Angular to the current major version if the migration spanned a release.

Ship this release like any risky one: the previous build ready to redeploy, error monitoring watched for the first days, and the end-to-end suite run against production after deploy.

If you chose the rewrite instead, the cutover is the risky part, so make it gradual: put a reverse proxy in front, send one route at a time to the new Angular app, share login through the same session or token, and keep each switch behind a flag you can turn back.

Common pitfalls in an AngularJS to Angular migration

These are the problems we see most when a migration has stalled.

  • Skipping preparation. Bootstrapping the hybrid app on top of $scope controllers means every conversion is a rewrite of that screen. The component-style refactor in step 2 is what makes step 4 mechanical.
  • Change detection storms. With UpgradeModule, every Angular change detection cycle triggers an AngularJS digest. Heavy watchers or timers in old code show up as a slow app; profile early and consider downgradeModule for large pages.
  • Two HTTP stacks that disagree. $http and HttpClient interceptors drift apart on token refresh or error handling, and users get logged out on one half of the app. Route both through one auth service.
  • Promises versus observables. AngularJS callers expect $q promises with .then(). A converted service that now returns RxJS observables breaks them silently, so add a firstValueFrom adapter at the boundary until the callers are converted too.
  • Global CSS leaking. Old stylesheets written for AngularJS markup style Angular components by accident. Scope new styles and remove old selectors as screens move.
  • Third-party directives left to the end. A grid or date picker used on every screen blocks the final cutover if nobody decided its replacement in the audit.
  • Router double ownership. Running both routers without location sync breaks the back button and deep links, which users notice first.
  • A migration branch. A long-lived branch that never merges is a rewrite under another name. Merge to main every sprint behind the bridge.

How long it takes, and how to run it

We do not publish a formula, because the honest answer from the audit is “it depends on the ratio of components to scopes and on how many third-party directives you have”. What we can say is how to run it so the estimate holds:

  • Run it as a stream alongside feature work, not as a freeze. A small dedicated pod (often two engineers and a tech lead reviewing) migrating leaf-first makes steady, visible progress without blocking the product team. If you want engineers inside your own team instead, you can hire Angular developers who have run ngUpgrade migrations before.
  • Ship on every sprint. Each converted feature goes to production behind the bridge, so there is no big-bang release at the end.
  • Track a single number weekly: the count of AngularJS components remaining. When it is visible, it goes down.

Where to start today

If you are reading this with a live AngularJS application, the first three actions are cheap and reversible: upgrade to AngularJS 1.8 if you are behind, arrange extended support for the duration, and commission the audit. The audit turns a vague worry into a ranked backlog and a migrate-or-rewrite decision you can defend.

We run these audits and migrations as part of our Angular development work, with the six phases set out on that page, and the project scoper will give you a sense of team shape for either path. If you have a migration under way and it has stalled, the usual culprits are routing and untested shared state; both are fixable without starting over.

FAQ

Questions this guide gets asked

Something not covered here? Ask a tech lead. We reply within one business day.

Audit the 1.x app, refactor it to components, ES modules and TypeScript, bootstrap a hybrid app with ngUpgrade, convert services and then components leaf-first, move routing, keep end-to-end tests green throughout, and remove AngularJS in a final cutover release. Rewrite instead when the app is small or being redesigned.

No. Google ended long-term support for AngularJS on 31 December 2021. Security fixes come only from paid third-party extended-support vendors, and new browser, build-tool and dependency versions are not tested against it.

It depends on the size and health of the codebase, not the calendar. A small 1.x app already built from components can move in a few sprints; a large app built on scopes and jQuery plugins is a multi-month programme run alongside feature work. The audit turns that into a real estimate.

Migrate incrementally when the application is large, in daily use and still changing, because the hybrid approach lets you ship throughout. Rewrite when the app is small, when the UI is being redesigned anyway, or when the codebase is in such poor shape that you would be preserving problems rather than code.

The current major version. There is no need to pass through Angular 2, 4 or any intermediate release: the hybrid app is created on the current Angular from day one, and new code uses standalone components and signals. Upgrade AngularJS itself to 1.8 first.

ngUpgrade (@angular/upgrade) is Angular's official bridge for running AngularJS and Angular in the same page. It lets Angular components be used inside AngularJS templates and the reverse, shares services across both injectors, and keeps change detection in step so you can convert the application one piece at a time.

Yes, two ways. Package new Angular features as Angular elements (custom elements) inside the old templates, or put a reverse proxy in front and move whole routes to a separate Angular app one at a time. Both avoid a shared injector; both need care with shared login and state.

Yes. The ui-router team publishes an angular-hybrid package that lets ui-router handle routing across both AngularJS and Angular views during the hybrid phase. Moving to the Angular Router is a later step, done once most views are Angular.

Next step

Want a second opinion on your project?

Send us a few lines. A tech lead will give you an honest recommendation, even if it is not us.

  • We speak in hours, not days
  • Written quote within 48 hours
  • Deployment included, you own the code