【转】Understanding the Angular Boot Process

时间:2022-09-25 09:19:06

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

 

【转】Understanding the Angular Boot Process

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.

 

【转】Understanding the Angular Boot Process

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. OS开发拓展篇—应用之间的跳转和数据传

    iOS开发拓展篇-应用之间的跳转和数据传 说明:本文介绍app如何打开另一个app,并且传递数据. 一.简单说明 新建两个应用,分别为应用A和应用B. 实现要求:在appA的页面中点击对应的按钮,能够 ...

  2. String.Format 全汇总

    C#格式化数值结果表 字符 说明 示例 输出 C 货币 string.Format("{0:C3}", 2) $2.000 D 十进制 string.Format("{0 ...

  3. js让iframe高度自动

    HTML: <iframe id="yb_if" width="940px" src="连接" frameborder=0 allow ...

  4. 米兰站热卖:奢侈品电商困局已破?-搜狐IT

    米兰站热卖:奢侈品电商困局已破?-搜狐IT 米兰站热卖:奢侈品电商困局已破?

  5. DrawerLayout和ActionBarDrawerToggle

    说明:DrawerLayout的作用就是左侧滑出.右侧滑出菜单.需要和ActionBarDrawerToggle来配合使用.如果对ActionBar不理解,请先熟悉ActionBar. 1.首先配置D ...

  6. 分析业务模型-类图(Class Diagram)

    分析业务模型-类图(Class Diagram)     分析业务模型-类图(Class Diagram)(上) 摘要:类图(Class Diagram)可能是用得最多的一种UML图.类图的基本语法并 ...

  7. Groovy 设计模式 -- 装饰器模式

    http://groovy-lang.org/design-patterns.html#_chain_of_responsibility_pattern 装饰器模式, 起到美化原始对象的作用. 一个被 ...

  8. 使用PowerDesigner 15进行逆向工程生成数据库图表时,列的注释问题

    上一章讲了对数据库进行逆向工程生成图表操作,可能会遇到无法生成注释的问题: 一.解决PowerDesigner逆向工程没有列注释 1.打开PowerDesigner 15,选择菜单:File→Reve ...

  9. W7500S2E串口转以太网

    概述 W7500S2E是一系列串口转以太网模块,支持TCP Server.TCP Client和UDP三种工作模式,串口波特率最高可达460,800bps,并提供配套的上位机配置软件,也可通过网页或A ...

  10. Springboot通过cors解决跨域问题(解决spring security oath2的&sol;oauth&sol;token跨域问题)

    @Bean public CorsFilter corsFilter() { final UrlBasedCorsConfigurationSource source = new UrlBasedCo ...