【转】Understanding the Angular Boot Process

原文: https://medium.com/@coderonfleek/understanding-the-angular-boot-process-9a338b06248c

---------------------------------------------------------------------------------

For newcomers to Angular 2+ (now referred to simply as Angular), the struggle is always adapting to the drastic change from the structure they are already familiar with in AngularJS. And for those that have never seen AngularJS but began their Angular journey with the new kid on the block, the fact that Angular includes a bootstrap process can send a rather unpleasant but rather misguided tone that Angular just decided to be a black sheep among its counterparts (as if favoring Typescript was not enough).

However, these misconceptions only arise when you have not fully understood the inner workings of Angular. When you fully understand it you will realize and start to appreciate its structure and rather than seeing it has “complex” you see it as highly organized.

In this short article (one of many devoted to demystifying the structure of Angular), i will break down the Angular bootstrap process, simply put, how an angular app starts up.

Then entry point to every Angular application is the main.ts file which contains this last line:

The platformBrowserDynamic() part of this line of code indicates that we are about to boot Angular in a browser environment. As Angular can be used in Javascript host environments asides the browser (e.g. on the server or in a web worker), its thus imperative that we specify the environment in which our App is to be booted.

The bootstrapModule() function helps bootstrap our root module taking in the root module as its argument.

AppModule is our root module which is the entry module for our application, this can actually be any of the modules in our application but by convention AppModule is used as the root module.

In our AppModule, we then need to specify the component that will serve as the entry point component for our application. This happens in our app.module.ts file where we import the entry component (conventionally AppComponent) and supply it as the only item in our bootstrap array inside the NgModule configuration object.

And there you have it, that concludes our Angular boot process. A recap of the steps

  1. Specify the enviroment in which your Angular App is running
  2. Use the bootstrapModule() function to boot your entry module by supplying the module as an argument.
  3. Inside the root module, specify your entry point component in the module configuration object.

Now that doesn’t look complicated does it :).

原文地址:https://www.cnblogs.com/oxspirt/p/9815511.html

时间: 2024-10-11 00:18:31

【转】Understanding the Angular Boot Process的相关文章

The Boot Process at a Glance x86/x64系统启动过程解析

哥又来干体力活了.人肉翻译一下: The Boot Process at a Glance This section explains the boot process in sufficient detail to understand the system address map and other bus protocol-related matters that are explained later in this article. You need to have a clear u

The Kernel Boot Process.内核引导过程

原文标题:The Kernel Boot Process 原文地址:http://duartes.org/gustavo/blog/ [注:本人水平有限,只好挑一些国外高手的精彩文章翻译一下.一来自己复习,二来与大家分享.] 上一篇文章解释了计算机的引导过程,正好讲到引导装载程序把系统内核镜像塞进内存,准备跳转到内核入口点去执行的时刻.作为引导启动系列文章的最后一篇,就让我们深入内核,去看看操作系统是怎么启动的吧.由于我习惯以事实为依据讨论问题,所以文中会出现大量的链接引用Linux 内核2.6

[archlinux] linux boot process/order/stage

信息量好大 --! 神教读物,无人能比: https://wiki.archlinux.org/index.php/Arch_boot_process IBM的高质量文档 https://www.ibm.com/developerworks/library/l-linuxboot/ https://www.freedesktop.org/software/systemd/man/bootup.html# init process: https://en.wikipedia.org/wiki/Li

Linux Booting Process: A step by step tutorial for understanding Linux boot sequence

One of the most remarkable achievement in the history of mankind is computers. Another amazing fact about this remarkable achievement called computers is that its a collection of different electronic components, and they work together in coordination

In Depth : Android Boot Sequence / Process

What happened when I press power on button in my Android device ? What is Android boot sequence ? What is linux kernel ? What is different between desktop linux kernel and Android linux kernel ? What is bootloader ? What is Zygote ? What is x86 and A

Kernel boot options

There are three ways to pass options to the kernel and thus control its behavior: When building the kernel. Most of this book discusses these options. When starting the kernel. Usually, parameters are passed to the kernel when it is invoked from a bo

Angular vs React---React-ing to change

这篇文章的全局观和思路一级棒! The Fairy Tale Cast your mind back to 2010 when users started to demand interactive web applications. Back then the only real solution was jQuery, and I’d love to know how many of us have sat debugging 1000+ lines of jQuery at some po

10.5.2 Boot Block 启动块 - 操作系统教程

简单一篇文章明白地讲解了计算机操作系统的启动过程 OPERATING SYSTEM CONCEPTS ABRAHAM SILBERSCHATZ PETER BAER GALVIN GREG GAGNE 10.5.2 Boot Block For a computer to start running-for instance, when it is powered up orrebooted-it must have an initial program to run. This initial

linux /boot FHS翻译

/boot: Static files of the boot loader Purpose: This directory contains everything required for the boot process except configuration files not needed at boot time and the map installer. Thus /boot stores data that is used before the kernel begins ex