Prikazovanje samo
0:02
S… Speaker 1 (107. Module Introduction)
Welcome to a new module in this course.
0:04
S… Speaker 1 (107. Module Introduction)
This module is about services and dependency injection.
0:09
S… Speaker 2 (107. Module Introduction)
Now,
0:09
S… Speaker 1 (107. Module Introduction)
what is that?
0:12
S… Speaker 1 (107. Module Introduction)
Let's start with services.
0:13
S… Speaker 1 (107. Module Introduction)
What are services?
0:15
S… Speaker 1 (107. Module Introduction)
Let's consider this application.
0:17
S… Speaker 1 (107. Module Introduction)
We get an app component,
0:19
S… Speaker 1 (107. Module Introduction)
an about component,
0:20
S… Speaker 1 (107. Module Introduction)
an user component,
0:21
S… Speaker 1 (107. Module Introduction)
and a user detail component.
0:23
S… Speaker 2 (107. Module Introduction)
Now,
0:24
S… Speaker 1 (107. Module Introduction)
we might have some methods in those components.
0:27
S… Speaker 1 (107. Module Introduction)
Let's say we want to log some data to the console in the about
0:31
S… Speaker 1 (107. Module Introduction)
component and in the user detail component.
0:34
S… Speaker 1 (107. Module Introduction)
And somehow this log statement is pretty similar.
0:37
S… Speaker 1 (107. Module Introduction)
So pretty much the same text.
0:39
S… Speaker 1 (107. Module Introduction)
So we're basically repeating ourselves here.
0:41
S… Speaker 1 (107. Module Introduction)
We're duplicating code in two different components.
0:44
S… Speaker 1 (107. Module Introduction)
Let's say in the user component,
0:47
S… Speaker 1 (107. Module Introduction)
we also want to access some data,
0:50
S… Speaker 1 (107. Module Introduction)
some array of users maybe.
0:51
S… Speaker 1 (107. Module Introduction)
And maybe we also don't know if we will later use
0:55
S… Speaker 1 (107. Module Introduction)
that in some other part of our application.
0:57
S… Speaker 1 (107. Module Introduction)
Both use cases.
1:00
S… Speaker 1 (107. Module Introduction)
duplication of code,
1:01
S… Speaker 1 (107. Module Introduction)
and data storage,
1:04
S… Speaker 1 (107. Module Introduction)
providing data,
1:05
S… Speaker 1 (107. Module Introduction)
are typical use cases for a service,
1:08
S… Speaker 1 (107. Module Introduction)
because a service is basically just another piece in your Angular
1:12
S… Speaker 1 (107. Module Introduction)
app, another class you can add,
1:14
S… Speaker 1 (107. Module Introduction)
which acts as a central repository,
1:17
S… Speaker 1 (107. Module Introduction)
as a central business unit,
1:20
S… Speaker 1 (107. Module Introduction)
you could say, something where you can store,
1:21
S… Speaker 1 (107. Module Introduction)
where you can centralize your code in.
1:24
S… Speaker 1 (107. Module Introduction)
So we could create a log service,
1:26
S… Speaker 1 (107. Module Introduction)
for example, to centralize our log statement.
1:29
S… Speaker 1 (107. Module Introduction)
We could create a user service to manage the data storage here.
1:33
S… Speaker 1 (107. Module Introduction)
Let's see this in a real app so that it becomes more clear though.

Ta prepis je ustvaril AI (avtomatsko prepoznavanje govora). Lahko vsebuje napake – preverite proti originalnemu zvoku za kritično uporabo. Politika AI

❤️ Ljubezen STT.ai?
Povzetek
Kliknite Povzetek, da ustvarite povzetek AI tega transkripta.
Povzetek...
Vprašaj AI o tem transkriptu
Vprašajte karkoli o tem prepisu – AI bo našel ustrezne oddelke in odgovor.