Angular 5 Learning Experience — Part 2
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 :
- <<element level>> → <app-element>
- <<.classlevel>> → <p class=”classlevel”>
- [attributelevel> → < p app-element>