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

The component – a controller and a building block

In the context of MVC, the component is the V and C, the view and the controller. The component allows you to define either a separate template file or an inline template. The template is the view part.

The controller in this context is a component class file that handles user interactions and also fetches the necessary data for the template to display.

Components have come to be a central concept for a lot of frameworks that are popular today, such as React, Vue.js, and Polymer. A component can take inputs, which are either data or methods. It consists of a piece of code and an HTML template, which render interesting data, living on the component. A component in Angular consists of three major parts:

  • A decorator function
  • A class
  • A template

A component consists of a controller class and a template. It can play two different roles in an Angular application: either it can be the responder to the route or it can serve as a building block. In the first case, Angular will instantiate it when a new route happens and respond with that component. In the latter case, the component is created directly by existing as a child component within another component.

We will explain next what we meant by the previous paragraph.

主站蜘蛛池模板: 信宜市| 南澳县| 崇阳县| 霍州市| 高淳县| 时尚| 浑源县| 镇安县| 遂宁市| 嘉祥县| 屏南县| 泸溪县| 微山县| 社会| 南平市| 安达市| 南昌县| 简阳市| 长治市| 浮梁县| 恩平市| 镇坪县| 舒兰市| 若尔盖县| 彰化县| 无极县| 新蔡县| 容城县| 阳东县| 曲水县| 车险| 会同县| 隆安县| 长沙市| 达拉特旗| 长乐市| 太和县| 宝山区| 石城县| 柳林县| 中超|