Home > Web Front-end > JS Tutorial > In-depth understanding of Component components in Angular

In-depth understanding of Component components in Angular

青灯夜游
Release: 2021-04-19 09:33:45
forward
2224 people have browsed it

This article will introduce to you the In-depth understanding of Component components in Angular component in Angular. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

In-depth understanding of Component components in Angular

Angular In-depth understanding of Component components in Angular


In-depth understanding of Component components in Angular is what makes up an Angular application Basic and Core. In layman's terms, components are used to package specific functions, and the orderly running of the application depends on the coordination between components. [Related tutorial recommendations: "angular tutorial"]

In-depth understanding of Component components in Angular essential elements

In-depth understanding of Component components in Angular

    ## @In-depth understanding of Component components in Angular (component metadata decorator)
@In-depth understanding of Component components in Angular The role of the decorator is to tell the Angular framework how to handle Typescript classes. It contains multiple properties, and the values ​​of these properties are called metadata. . Angular will render the component and execute the component's logic based on the metadata value.

    Template (template)
Template is used to define the appearance of a component. The template exists in the form of html and tells Angular how to render the component. We can use Angular's data binding syntax in the template to render data from the controller.

    Controller (controller)
The controller is an ordinary Typescript class, which will be decorated by the @In-depth understanding of Component components in Angular decorator. The controller contains All properties and methods of the component, and most of the page logic are written in the controller. The controller communicates with the template through data binding, the template displays the controller's data, and the controller handles events that occur on the template.

Example

import { In-depth understanding of Component components in Angular } from '@angular/core';

@In-depth understanding of Component components in Angular({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
  providers: [AppService],
})
export class AppIn-depth understanding of Component components in Angular {
  title = 'app demo';

  .....
}
Copy after login

  • selector
##@In-depth understanding of Component components in Angular decorator specification CSS selector, which tells Angular to create and insert an instance of the component once the tag corresponding to this selector is found in the template HTML.

    templateUrl
templateUrl specifies an HTML file as the template for the component. You can also use the value of the template attribute to provide an inline HTML template

    styleUrls: ['./app.component.css']
styleUrls points to a set of CSS files in which styles to be used by components can be written.

    providers
An array of service providers required by the current component

    AppIn-depth understanding of Component components in Angular
The controller of the component, a Typescript class decorated by a decorator.

In-depth understanding of Component components in Angular Other elements

In-depth understanding of Component components in Angular元素For more programming-related knowledge, please visit:

Programming Teaching

! !

The above is the detailed content of In-depth understanding of Component components in Angular. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template