You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,3 +107,25 @@ A: Yes (?)
107
107
108
108
A: Components, pipes, directives
109
109
110
+
## Services Questions:
111
+
112
+
**What is the use case of services?**
113
+
114
+
A: One very common use case is providing data to components, often by fetching it from a server. Though there’s no real definition of service from Angular point of view – it could do almost anything (e.g., logging is another common use case, among many).
115
+
116
+
**How are the services injected to your application?**
117
+
118
+
A: Via Angular’s DI (Dependency Injection) mechanism
119
+
120
+
**Why is it a bad idea to create a new service in a component like the one below?**
121
+
`let service = new DataService();`
122
+
123
+
A: The object may not be created with its needed dependencies.
124
+
125
+
**How to make sure that a single instance of a service will be used in an entire application?**
126
+
127
+
A: Provide it in the root module.
128
+
129
+
**Why do we need provider aliases? And how do you create one?**
130
+
131
+
A: To substitute an alternative implementation for a provider. Can create like so: `{ provide: LoggerService, useClass: DateLoggerService }`
0 commit comments