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