In this article, We will discuss about What is Component in angular 2.
Component is a class to combine data,logic and template[View] as one Unit.
The class applied with @Component decorator function is considered as Component class.
Syntax:-
----------
@Component({
selector : Specify element name to component,
template : Specify inline markup to component,
templateUrl : Specify html markup to component,
style : Specify inline style to component,
styleUrl : Specify external style to component
})
class classname
{
variable declarations
method declarations
}
Example:-
------------
@Component({
selector : "my-app",
template : "<h2>Welcome to Angular 2</h2>";
style : ["h2{color:red}"]
})
class appComponent
{}
0 comments:
Post a Comment