Angular 5 Learning Experience — Part 2

Kathiravan
1 min readJul 5, 2018

--

Components

The @Component decorator identifies the class immediately below it as a component class, and specifies its metadata. So basically we need to create a class first ( to hold the component logic) and then Decorate with @Component

This @Component decorator is class level decorator. We will what is class level decorator we will see later. Let us what the meta data @Component looks like

What we seeing above gist is we are creating a CalComponent class and it is decorated with @Component.It accepts javascript object with different key’s. We have used only few key’s. selector:Denotes dom element. In our case the HTML element will be <cal-root></cal-root>. template Denotes the inline HTML . For full list of @Component MetaData refer below link.

selector :

  1. <<element level>> → <app-element>
  2. <<.classlevel>> → <p class=”classlevel”>
  3. [attributelevel> → < p app-element>

Component Meta Data Link

Sample Component in StackBlitz

Part — 3 Continued here

--

--

Kathiravan
Kathiravan

No responses yet