原文: 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 :).

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

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

    哥又来干体力活了.人肉翻译一下: The Boot Process at a Glance This section explains the boot process in sufficient d ...

  2. Ubuntu 16.04 启动错误 "a start job is running for hold until boot process finishes up"

    老司机也差点翻船... 升级16.04的时候,将默认启动管理器(default display manager)选为gm3(gnome3)了(应该使用默认的lightgm)如果改成gm3,好像是nvi ...

  3. The Kernel Boot Process.内核引导过程

    原文标题:The Kernel Boot Process 原文地址:http://duartes.org/gustavo/blog/ [注:本人水平有限,只好挑一些国外高手的精彩文章翻译一下.一来自己 ...

  4. [archlinux] linux boot process/order/stage

    信息量好大 --! 神教读物,无人能比: https://wiki.archlinux.org/index.php/Arch_boot_process IBM的高质量文档 https://www.ib ...

  5. In Depth : Android Boot Sequence / Process

    In Depth : Android Boot Sequence / Process What happened when I press power on button in my Android ...

  6. A Guide to the Multiboot Process

    A Guide to the Multiboot Process The XP and Vista boot process in general.The Windows dual and multi ...

  7. Microsoft Windows CE 5.0 Board Support Package, Boot Loader, and Kernel Startup Sequence

    Summary Learn about the initial, low-level startup sequence and the hardware platform functions that ...

  8. Angular vs React---React-ing to change

    这篇文章的全局观和思路一级棒! The Fairy Tale Cast your mind back to 2010 when users started to demand interactive ...

  9. Kernel boot options

    There are three ways to pass options to the kernel and thus control its behavior: When building the ...

随机推荐

  1. iOS Sprite Kit教程之滚动场景

    iOS Sprite Kit教程之滚动场景 滚动场景 在很多的游戏中,场景都不是静止的,而是滚动的,如在植物大战僵尸的游戏中,它的场景如图2.26所示. 图2.26  植物大战僵尸 在图2.26中,用 ...

  2. 【原创】自己动手写的一个查看函数API地址的小工具

    C开源代码如下: #include <stdio.h> #include <windows.h> #include <winbase.h> typedef void ...

  3. Shell 学习笔记之运算符

    基本运算符 算术运算符 val = expr 2 + 2 需要注意的是 表达式和运算符之间需要有空格(比如2 + 2,不能是2+2) 两边最外面的字符是`,在esc键下面,不是引号哦 乘号* 前面必须 ...

  4. Redis篇

    一:下载redis 官网地址:http://redis.io/     如果系统没有安装make,请查看mysql篇 wget http://download.redis.io/redis-stabl ...

  5. 主动找智能钥匙 PKE取代RKE是大势所趋

    http://taobao.autos.cn.yahoo.com/ypen/20111128/725214.html 近日,在车友论坛上的一个热帖<悲喜交加:1分钟就能复制汽车遥控器?>在 ...

  6. 电感式DC/DC变换器工作原理

    http://www.amobbs.com/thread-3293203-1-1.html 首先必须要了解电感的一些特性:电磁转换与磁储能.其它所有参数都是由这两个特性引出来的. 电感回路通电瞬间 断 ...

  7. Short Circuit Protection Circuit

    http://www.daycounter.com/Circuits/Short-Circuit-Protection/Short-Circuit-Protection.phtml Short cir ...

  8. OllyDbg 使用笔记 (十二)

    OllyDbg 使用笔记 (十二) 參考 书:<加密与解密> 视频:小甲鱼 解密系列 视频 演示样例程序下载地址:http://pan.baidu.com/s/1eQiV6aI 安装好程序 ...

  9. failed to get the task for process XXX(解决方案)

    引人: iOS真机调试程序,报如下错误信息: failed to get the task for process XXX 原因: 证书问题,project和targets的证书都必须是开发证书,AD ...

  10. 命令行编译工具NMAKE

    简介 大家已经习惯于微软提供的功能强大的IDE,已经很少考虑手动编连项目了,所谓技多不压身,有空的时候还是随我一块了解一下命令行编译. C/C++/VC++程序员或有Unix/Linux编程经验应该很 ...