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.
问题:
回答1:
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.
回答2:
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.