Angular.js and Angular hybrid with ngUpgrade but no module loader

  angular, angularjs, ng-upgrade

I’m attempting to port a legacy angular.js app (that formerly used Grunt, and all .js files referenced directly from index.html) to run side-by-side with Angular using Angular CLI. I’m using the official upgrade guide as well as referencing this tutorial.

In the tutorial, they move all the scripts from index.html into the ‘scripts’ section of the Angular.json. However in the official Angular upgrade guide, they use a lazy loader to not load the ng-app until the user navigates to a legacy page. This means the ‘script’ approach taken by the tutorial cannot work in combination with a lazy loader, as the controllers reference an app that does not yet exist when they first load.

I’m looking for the easiest/fastest way to get things up and running. Since I did not first convert the legacy angular.js site to use a module loader as the official upgrade guide suggests, is there an easy way to get things running, using a method similar to the 3rd party tutorial? I’m not sure how to convert it to a bootstrap method that is compatible with having all scripts bundled into the angular.json.

Or, if I really must change the entire legacy project to use a module loader, how do I do that at this point?

Source: AngularJS Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.