which file runs first in an angular 4 app when i run the app?

In Angular app,

Index.html is the start and it then main.ts

After Index.html, main.ts. Which tells which file to run. Which is mainly to bootstrap

main.ts is the entry point of your application, compiles the application with just-in-time and bootstraps the application .Angular can be bootstrapped in multiple environments we need to import a module specific to the environment. in which angular looks for which module would run first.

// The browser platform with a compiler

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';


// The app module

import { AppModule } from './app/app.module';

Look at the following diagram which explains the structure very well. enter image description here


angular.json -> angular-cli configuration file main.ts -> Angular module bootstrap application file. Set the entry module for your application. app.module.ts -> Based upon your entry module, it configures which component will load first from that module and what others dependency modules, components, pipes, services.


Only one thing which is stranger, if you add a 'console.log' before '@Component({' of 'app.component.ts', you will find that one will be called first.

beacause angular does not work in asynchronously.angular follow non-blocking