What Are Components in Angular 4

What Are Components in Angular 4

Components are the main magic feature which Angular has, imagine it that way, you have a website or web application which is a single page application, it starts with a single page which has the main component \ but from there you can have each part of this site loaded from different component which includes different (script and html).

Components live in /src/app, components are structures by thre main parts

Angular 4 Components
#1 Import section is where you import the needed component from angular, so some components will have dozens of imports needed as a dependency fo used code.
#2 The decorator as in that figure it starts with @component which that is the part that defines it as a component, then there are several properties for that component, in that figure example the selector is showing the name of the component while templateUrl and styleUrls showing both the html and css which wll be connected to that component.
In that section you can add other properties too which we will be discussing in later articles.

#3 This is the main class which holds all the functions and code needed for that component.

Click here to learn how to create Angular 4 components.

 


Subscribe to
for video tutorials updates

2 thoughts on “What Are Components in Angular 4

  1. Pingback: What is Angular 4 Service, How to Use it and Create it

  2. Pingback: Angular 4 Component Structure and Properties

Comments are closed.