Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 24b6004

Browse files
Services questions
1 parent 06c4388 commit 24b6004

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,25 @@ A: Yes (?)
107107

108108
A: Components, pipes, directives
109109

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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /