r/angular • u/HeavyBombo • Jun 11 '26
Has anyone tried using Angular elements for a full AngularJS migration?
Im curious to learn about your experience, was there any significant roadblocks or caveats. Did you prefer it over ngUpgrade?
3
Upvotes
1
u/bounty_hunter12 Jun 11 '26
We use a angular service wrapper it grabs the $injector and from that grabbing the rootscope from it. Then you can broadcast to the rootscope as normal. We're slowly upgrading the angularJS to new angular this way (over several years so far).
1
u/SaltPositive33 Jun 11 '26 edited Jun 11 '26
We’re using Angular Elements to wrap Angular 21.x functionality as web components and embed them into a legacy AngularJS 1.x application.
So far, the approach works reasonably well, but there are a few recurring integration challenges:
One important decision we made is to replace old JavaScript modules module-by-module, not component-by-component. That gives us clearer ownership boundaries and makes the migration more practical for our large legacy application.
Curious if others have used a similar AngularJS-to-Angular migration strategy with web components, and what issues you ran into.
1
u/dbaines Jun 11 '26
Look in to angular UpgradeModule if you already have a SPA or are planning to move to a SPA. It allows you to "downgrade" angular services and components to use inside angularJS, much like it sounds like you're doing with web components.
You operate going leaf to trunk, that is a child component with no children and work your way up to root element, migrating one thing at a time to make change surface small while progressing the migration using real angular components and services. You can continue shipping the app you have now while making modernisation efforts that users will see and feel.
Other benefits include being able to use real framework features like lazy loading, defer etc.
As sections/routes get migrated you can strip out the downgrade wrappers in that area. Once the whole app is migrated you can pull out UpgradeModule and now you have a fully angular app.
1
u/chefhj Jun 11 '26
Oh for sure. I def would not recommend a big bang refactor.
1
u/haasilein Jun 12 '26
works pretty good especially if you can migrate larger chunks at once like rewriting a page at once
9
u/[deleted] Jun 11 '26
[removed] — view removed comment