A component is something that's visible to the end user and which might be reused many times among an application. The figure below demonstrate the structure of an Angular 2 component.
Template -
An Angular component includes a template which lays out the user interface fragment to finding a view for the application. It is created with HTML and defines what is rendered on the page. Using Angular binding and directives in the HTML will power up the view.
Class-
The class is created with TypeScript. The class contains the properties or data elements available for use in the view. For example, if one want to display a title in the view, can define a class property for that title.
The class also contains methods which are the functions for the logic needed by the view. For example, if one want to show and hide an image, should write the logic in a class method.
Metadata -
A component also has metadata which provides additional information about the component to Angular. It is this metadata that defines this class as an Angular component. The metadata is defined with a decorator. A decorator is a function that adds metadata to a class, its members or its method arguments. So a component is a view defined in a template. Its associated code defined with a class and metadata defined with a decorator.
The image below explain the component look in TypeScript. The complex code in the image is divided into chunks for simple understanding.
From the above image the
class defines the properties and methods needed by the view. The
@component decorator defines the
metadata and the metadata includes the
templates that lays out the view managed by this component. And
imported the required members.