原文: 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. Codeforces Round #461 (Div. 2)

    A - Cloning Toys /* 题目大意:给出两种机器,一种能将一种原件copy出额外一种原件和一个附件, 另一种可以把一种附件copy出额外两种附件,给你一个原件, 问能否恰好变出题目要求数 ...

  2. iptables配置允许mysql远程访问

    vi /etc/sysconfig/iptables iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCE ...

  3. Alpha 冲刺报告5

    组长:吴晓晖 今天完成了哪些任务: 将服务端程序基本部署在阿里云上,还未进行测试 完成了手写记录的代码实现 处理团队问题 为明天的编程任务做准备 展示GitHub当日代码/文档签入记录: 明日计划: ...

  4. Java NIo 笔记001

    1. Channel Channel接口只提供了两个方法: package java.nio.channels; public interface Channel { public boolean i ...

  5. BZOJ 4403: 序列统计 数学 lucas

    4403: 序列统计 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4403 Description 给定三个正整数N.L和R,统计长度在 ...

  6. IO流-批量修改文件名称案例

    /* *   源文件名:   桌面-我们今天学习IO流了哈哈哈哈-001.jpg *   修改后文件名:  桌面-000x.jpg */public class File_listFiles_upda ...

  7. C++反汇编-继承和多重继承

    学无止尽,积土成山,积水成渊-<C++反汇编与逆向分析技术揭秘> 读书笔记 一.单类继承 在父类中声明为私有的成员,子类对象无法直接访问,但是在子类对象的内存结构中,父类私有的成员数据依然 ...

  8. windows设置共享

    设置共享: 添加用户 点击添加 设置权限 然后别人就可以查看了. 查看共享: 删除共享:

  9. JDBC 连Sql Server 接数据库--The TCP/IP connection to the host localhost, port 1433 has failed

    原文:https://blog.csdn.net/qq_39241986/article/details/80848855 这样的错误,你有遇到过吗? The TCP/IP connection to ...

  10. 做iphone5适配时,一定要做好图片大小的调整。