官术网_书友最值得收藏!

Angular's main building blocks

Every application created using the Angular framework has five very important points that connect to each other and establish the basic architecture of the application:

  • Modules: Using the decorator @NgModule
  • Services: Using the decorator @Injectable
  • Components: Using the decorator @component
  • Templates: Views with data-bind and directives
  • Routes: Setting URL path to views 

Let's look at a simple blog page as an Angular application, built with components:

Angular components

The preceding diagram illustrates how components can be used to build a simple application.

A comparison between the preceding diagram and the five basic concepts of an Angular application would look as follows:

  • One module: blog.module.ts
  • A page component: blog.component.ts
  • A route to the blog page
  • A service to load the blog posts

There are also some additional components, such as Header, Post, and Pagination.

Note that the Header component belongs to the main module of the application (in this case, the AppModule), and the Post and Pagination components are part of the BlogModule.

As we move through this chapter, we will look more closely at the relationship between modules and components. Now, we will look at the life cycle of a component.

主站蜘蛛池模板: 闸北区| 昆山市| 南安市| 鸡泽县| 泰顺县| 拉孜县| 雷山县| 通山县| 台北县| 普格县| 衡阳县| 从化市| 蒙阴县| 望城县| 南召县| 中超| 瑞昌市| 且末县| 洛扎县| 旌德县| 绩溪县| 建湖县| 大悟县| 任丘市| 东乡族自治县| 柘城县| 固镇县| 肇州县| 叶城县| 怀宁县| 红原县| 连城县| 喜德县| 昌都县| 清河县| 扶绥县| 山西省| 卫辉市| 揭阳市| 德州市| 高邑县|