In my AngularJS app, I've many controllers js files.
These controllers (one.ctrl.js
,two.ctrl.js
,...
) needs to be included in my index.html
file.
Directory Structure:
app/
js/
controllers/
one.ctrl.js
two.ctrl.js
Currently, above js
files are included in index.html
file as follows.
index.html:
<!-- other html components -->
<script src="js/controllers/one.ctrl.js"/>
<script src="js/controllers/two.ctrl.js"/>
</body>
</html>
There are gonna be more *.ctrl.js
files which are required to be included in index.html
.
I need a way to automatically include all the *.ctrl.js
files in controllers
directory to index.html
.
Findings:
From some SO questions,
Load JavaScript and CSS files in folders in AngularJS
How can I include all JavaScript files in a directory via JavaScript file?
I found that it cannot be done automatically and needs some server side scripting or build tools.
My Question:
Currently, I'm using yeoman
which include grunt
for build tool.
So, my question is, How can those javascript files in a directory be automatically included in a html file?