0

We are creating a single page app with Angular routing. The problem is that the Javascript with the controller(s) need to be referenced. I want the js file to be downloaded dynamically on demand.

Is it mandatory to use a system like RequireJS ? Is there an alternative ?

stephan.peters
  • 963
  • 13
  • 35

2 Answers2

0

AngularJS is just a wrapper over pure JS to make a system that's defined in its documentation (MVC, two-way binding, directive and so on). So, you can download the JS and bind the controller defined in the file to the angular app (ng-app). You don't need to use RequireJS to load the file, rather you can use pure JS to do the work.

RAM
  • 2,413
  • 1
  • 21
  • 33
0

Most people use requirejs but you can do it in pure JS.

stackoverflow.com/questions/7718935/load-scripts-asynchronously

Community
  • 1
  • 1