Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm using angular 4 and I have a question. when I run the project and use ng serve, which file in my project renders first? there are so many files like main.ts, angular-cli.json, app.module and I don't understand whats going on when I run ng serve.

like image 620
fariba.j Avatar asked Aug 05 '18 05:08

fariba.j


2 Answers

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

like image 125
Sajeetharan Avatar answered Oct 18 '22 18:10

Sajeetharan


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.

like image 43
Abhishek Avatar answered Oct 18 '22 18:10

Abhishek