Setting up a bootstrap file

The main.ts file is your bootstrap file and it should have the following content:

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';

platformBrowserDynamic().bootstrapModule(AppModule);

What we do in the preceding code snippet is to provide the recently created module as an input parameter to the method call bootstrapModule(). This will effectively make the said module, the entry module of the application. This is all we need to create a working application. Let's summarize the steps we took to accomplish that:

  1. Create a component.
  2. Create a module and register our created component in its declaration property.
  3. Also register our component in the modules bootstrap property to make it serve as an application entry point. Future components we create just need to be added to the declarations property.
  4. Bootstrap our created module by using the said module as an input parameter to the bootstrapModule() method.

You as a reader have had to swallow a lot of information at this point and take our word for it. Don't worry, you will get a chance to get more acquainted with components in this chapter as well as Angular modules in upcoming chapters. For now, the focus was just to get you up and running by giving you a powerful tool in the form of the Angular CLI and show you how few steps are actually needed to have an app rendered to the screen.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset