Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setup angular js application index.html page to include only singe controller

I have written a angular application (MEAN) using nodejs in back-end. There are multiple modules in the application so have multiple controller.

We have to include all the controllers in the index.html file and new one as well if we added in any module.

I have checked the other application which are running on the same stack (MEAN) but in there source code i haven't found all the controllers.

So please help me around the same to optimize my application.

like image 704
RISHABH BANSAL Avatar asked Jul 10 '26 17:07

RISHABH BANSAL


1 Answers

Well then I'd suggest looking into Gulp as it allows you to concatenate and, if you want to, minify your codebase and place it into one file. That single file can then be referenced in your index.html

// Example - Concate the js files together and place them in the dist folder
gulp.task('js', function(){
  var src = ['../../file-name.js'];
  return gulp.src(src)
    .pipe(concat('main.js').on('error', gutil.log))
    .pipe(gulp.dest('dist/js').on('error', gutil.log))
});

This is an example of what I used when I worked with Angular1. Gulp places all my target files into the dist folder and into the main.js file which I reference in the index.html file.

 <script type="text/javascript" src="js/main.js"></script>
like image 199
Katana24 Avatar answered Jul 13 '26 11:07

Katana24