@@ -48,7 +48,7 @@ Answer: By using the two-way binding syntax [()] along with ngModel...
48
48
49
49
** How would you create a component to display error messages throughout your application?**
50
50
51
- A: Set up an ErrorHandler... TODO
51
+ A: Implement your own ErrorHandler and configure it in the list of providers for the modules you want it used in.
52
52
53
53
** How would you support logging in your Angular app?**
54
54
@@ -93,16 +93,17 @@ A: Root Module
93
93
94
94
A: provide components, directives, pipes to other modules for their usage.
95
95
96
- ** Why is it bad if SharedModule provides a service to a lazy loaded module?**
97
- A: TODO
96
+ ** Why is it (potentially) bad if SharedModule provides a service to a lazy loaded module?**
97
+
98
+ A: You will have two instances of the service in your application, which is often not what you want.
98
99
99
100
** Can we import a module twice?**
100
101
101
102
A: yes, and the latest import will be what is used.
102
103
103
104
** Can you re-export classes and modules?**
104
105
105
- A: Yes (?)
106
+ A: Yes.
106
107
107
108
** What kind of classes can you import in an angular module?**
108
109
@@ -119,6 +120,7 @@ A: One very common use case is providing data to components, often by fetching i
119
120
A: Via Angular’s DI (Dependency Injection) mechanism
120
121
121
122
** Why is it a bad idea to create a new service in a component like the one below?**
123
+
122
124
` let service = new DataService(); `
123
125
124
126
A: The object may not be created with its needed dependencies.
@@ -148,7 +150,7 @@ PA: fetch initial component data (e.g. from server).
148
150
149
151
** What would you consider a thing you should be careful doing on onNgInit()?**
150
152
151
- A: ??
153
+ A: You cannot expect the component's children's data-bound properties to have been checked at this point.
152
154
153
155
** What is the difference between onNgInit() and constructor() of a component?**
154
156
@@ -207,7 +209,7 @@ A: `<a [routerLink]="[’product.id’]">{{product.id}}</a>`
207
209
208
210
** How would you select a custom component to style it?**
209
211
210
- A: TODO
212
+ A: Using the ` :host ` pseudo-class selector in your component's styles.
211
213
212
214
** How do you reference the host of a component?**
213
215
0 commit comments