පෙන්වමින් පමණක්
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.

මෙම පරිවර්තනය AI විසින් ජනනය කරන ලදී (ස්වයංක්රීය කථාව හඳුනා). දෝෂ අඩංගු විය හැක - විවේචනාත්මක භාවිතය සඳහා මුල් ශ්රව්ය එරෙහිව තහවුරු. AI ප්‍රතිපත්තිය

❤️ ආදරය STT.ai? ඔබේ මිතුරන්ට කියන්න!
සාරාංශය
මෙම පරිවර්තනය AI සාරාංශයක් ජනනය කිරීමට සාරාංශ ක්ලික් කරන්න.
සාරාංශගත කිරීම...
මෙම පරිවර්තනය ගැන AI අහන්න
මෙම පරිවර්තනය ගැන යමක් අහන්න - AI අදාළ කොටස් සොයා සහ පිළිතුරු දෙනු ඇත.