Angular 8 2020 | What is Component in Angular Application #6

Опубликовано: 22 Январь 2020
на канале: Technical Babaji (Tarique Akhtar)
2,358
28

Components are like the basic building block in an Angular application. Components are defined using the @component decorator. A component has a selector, template, style and other properties, using which it specifies the metadata required to process the component.

Angular creates, updates, and destroys components as the user moves through the application

The metadata for a component tells Angular where to get the major building blocks that it needs to create and present the component and its view. In particular, it associates a template with the component, either directly with inline code, or by reference. Together, the component and its template describe a view.

selector: A CSS selector that tells Angular to create and insert an instance of this component wherever it finds the corresponding tag in template HTML. For example, if an app's HTML contains "app-hero-list", then Angular inserts an instance of the HeroListComponent view between those tags.

templateUrl: The module-relative address of this component's HTML template. Alternatively, you can provide the HTML template inline, as the value of the template property. This template defines the component's host view.

providers: An array of providers for services that the component requires. In the example, this tells Angular how to provide the HeroService instance that the component's constructor uses to get the list of heroes to display.

Templates and views
You define a component's view with its companion template. A template is a form of HTML that tells Angular how to render the component.

Views are typically arranged hierarchically, allowing you to modify or show and hide entire UI sections or pages as a unit. The template immediately associated with a component defines that component's host view. The component can also define a


Смотрите видео Angular 8 2020 | What is Component in Angular Application #6 онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Technical Babaji (Tarique Akhtar) 22 Январь 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 2,358 раз и оно понравилось 28 людям.