<aside> 💡

Points to consider before taking this

</aside>

/table



How does an angular application start?

  1. The app loads the index.js

  2. the index.js has links main.js that has the bootstrap code

  3. main.js compiles from main.ts

  4. main.ts imports AppModule . It has the following code → platformBrowserDynamic.bootstrapModule(AppModule)

    Here AppModule is being Bootsrapped.

  5. AppModule declares AppComponent in the bootstrap array of the @ngModule() declaration. So whatever you write in the app component gets rendered in the bootstrap module

angular-app-start.png



Modules

What is a Module in Angular?

A module is a set of Angular Components, Directives and Pipes that are interdependent and creates one full working unit

In Angular, the @NgModule decorator is used to define and configure Angular modules, which are essential for organizing and structuring your application.

The @NgModule decorator accepts a variety of properties to configure the module. Here are the key properties that can be passed to the @NgModule decorator:

  1. declarations (array of components):
  2. imports (array of modules):
  3. exports (array of components, directives, and pipes):
  4. providers (array of providers):
  5. bootstrap (array of components):
  6. entryComponents (array of components):
  7. schemas (array of schemas):
@NgModule({
  declarations: [AppComponent, MyComponent, MyDirective, MyPipe],
  imports: [CommonModule, FormsModule, HttpClientModule],
  exports: [MyComponent, MyDirective, MyPipe],
  providers: [MyService, { provide: APP_CONFIG, useValue: AppConfig }],
  bootstrap: [AppComponent],
  entryComponents: [MyDialogComponent],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
})


Components

What is a Component?

Components are the most basic UI building block of an Angular app. An Angular app contains a tree of Angular components. Angular components are a subset of directives, always associated with a template. Unlike other directives, only one component can be instantiated for a given element in a template.

In Angular, the @Component decorator is used to define metadata for a component. This metadata includes various properties and values that configure how the component behaves and interacts with the Angular framework. Here are some of the key values that can be passed as properties of the @Component decorator: