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

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.

主站蜘蛛池模板: 阳春市| 财经| 松滋市| 含山县| 达日县| 文水县| 汕尾市| 青川县| 瓮安县| 哈巴河县| 巴青县| 民勤县| 安溪县| 永丰县| 仙游县| 绥芬河市| 灵宝市| 镶黄旗| 澎湖县| 金塔县| 公安县| 白山市| 修水县| 阿拉尔市| 隆化县| 沭阳县| 苏尼特左旗| 新沂市| 临夏市| 定远县| 拜城县| 锦屏县| 池州市| 江川县| 盱眙县| 桐梓县| 磐安县| 青海省| 陈巴尔虎旗| 昭平县| 泽普县|