Statistics
The Highest Post







Statistics
Count 94
Avg 21.00
Min 21
Max 21
Angualr Top questions

Details



Peter Agyekum What is component decorators in Angular 4? The main objectives of decorators is to add some metadata to the class that will tell Angular 4 how to process a class. Or in another words, Decorators are functions that modify JavaScript classes. Angular has many decorators that attach metadata to classes so that it knows what those classes mean and how they should work. If we consider Component in Angular 4, we will have following options to configure. selector: — define the name of the HTML element in which our component will live. template or templateUrl: — It can be inline string or link an external html file. It allows us to tie logic from our component directly to a view. styles: — the styles array for our specific component. We can also link external CSS by styleUrls. directives: — another component directives we want to use inside our components. providers: — This is the place we are passing the services that we need insider our components. Immediately after this decorator or right to it, we need to export a class where our variables and functions reside that our component uses.
Related Topics