Components Flashcards
What is the minimum definition of a component?
A class with a Component decorator specifying a template
What is the difference between a component and a template?
A component is a directive with a template (representing a view)
What are different kinds of directives supported in Angular 2?
Structural, component, and attribute directives
How do components communicate with each other?
Various ways - for example: Input/Output properties, services, ViewChild/ViewContent
How do you create two way data binding in Angular 2.0?
By using the two-way binding syntax [()] (along with ngModel, if you’re doing this in the context of a form control element)
How would you create a component to display error messages throughout your application?
Implement your own ErrorHandler and configure it in the list of providers for the modules you want it used in
How would you support logging in your Angular app?
One way would be to use angular2-logger, which is a package inspired by log4j
How would you use the ngClass directive?
For example:
< div [ngClass]= “ {firstCondition: ‘ class1’ , secondCondition: ‘ class2’ } “ > … < /div >
What are dynamic components?
Components that are added at runtime (i.e. not fixed). For example, an ad banner component that is determined at runtime