Component like a lego pices in angular application If you don't know how to put them together properly you are not going to build any thing cool
over the next few minuts we are going to learn how to generate the component in side angular application
and How to put them together to define a view
what is a component
Components are the fundamental building blocks of Angular applications. They display data on the screen, listen for user input,
and take action based on that input.
A component is nothing but is a class with a view template and a Decorator. In simple words we can say that.
A component is composed of three things
Template
class
Decorator
---------
Defines the user interface So it contains HTML, Directive and Data Binding
class contains the view logic of the template as we know HTML is not a programming laguage so we write the logic inside the component class.
So like other object oriented programming laguage class contains property and methods. So normally property contains data for the templates
and method contains the the logic for the views. In angular we use typscripts for for defining the classes
And finally decorator which is provided angular we will use @Component decorator which adds addition metadata to the class. Once we add the
@component decorator to the class that classs becomes Components
Selector we can use with three different way
In-line template
In-line css
Nesting the component
Selector is basically a custom tag that can be use to represent a component
0 Comments