AngularJS App: How to include .js files into index.html

前端 未结 2 687
太阳男子
太阳男子 2021-01-31 08:48

I\'m new to angularJS. I managed to build a phonegap app using angularJS. The app is ok and running just fine. The problem is, now that I have a little more understanding on how

相关标签:
2条回答
  • 2021-01-31 09:27

    Use http://browserify.org/

    You get very simple and elegant commonjs modules and lots of amazing libraries from node.js in your browser.

    The code gets bundled into single js file.

    0 讨论(0)
  • 2021-01-31 09:33

    Referencing each script file in its own tag in index.html is definitely one way to do it, and the most straightforward. However, if you want something cleaner, take a look at one of the various guides to combining Angular with RequireJS:

    http://www.startersquad.com/blog/angularjs-requirejs/

    Does it make sense to use Require.js with Angular.js?

    This approach is aimed primarily at solving the problem of what order to load the files in order to satisfy dependencies, but it does also have the consequence of cleaning up the index.html...albeit at the cost of additional configuration elsewhere.

    0 讨论(0)
提交回复
热议问题