1
00:00:00,000 --> 00:00:04,800
[MUSIC].

2
00:00:04,800 --> 00:00:08,410
Let us now get a quick
understanding of angular services.

3
00:00:09,660 --> 00:00:10,910
What are they?

4
00:00:10,910 --> 00:00:12,130
Why do we need them?

5
00:00:12,130 --> 00:00:15,600
And how do they help in building
our angular application?

6
00:00:17,650 --> 00:00:20,480
The first question,
why do we need services?

7
00:00:22,400 --> 00:00:24,980
When we develop an angular repetition,

8
00:00:24,980 --> 00:00:29,675
we want to keep our component
classes as lean as possible.

9
00:00:29,675 --> 00:00:34,640
They should be mainly concentrated
on acting as the mediator between

10
00:00:34,640 --> 00:00:39,900
the view and the application logic between
the view and the model in some sense.

11
00:00:39,900 --> 00:00:44,344
So this component would
be providing a view

12
00:00:44,344 --> 00:00:49,960
model like ability for
our angular component.

13
00:00:49,960 --> 00:00:54,570
So in the component classes we want to

14
00:00:54,570 --> 00:00:59,440
delegate all the work of
fetching data from the server.

15
00:00:59,440 --> 00:01:05,650
Validating the user's input and
logging information to a service.

16
00:01:05,650 --> 00:01:11,290
So the service is a functionality that
is available to provide these kind of

17
00:01:11,290 --> 00:01:17,260
features that our component classes
can leverage to get their work done.

18
00:01:18,760 --> 00:01:23,420
So that is where the need for
a service comes in.

19
00:01:23,420 --> 00:01:28,720
So we try to factor out the application
logic into services and let them do all

20
00:01:28,720 --> 00:01:35,120
the heavy lifting of performing much
of the application level logic,

21
00:01:35,120 --> 00:01:41,480
and the services will take care of things
like communicating with the server,

22
00:01:41,480 --> 00:01:45,040
input validation and many other features.

23
00:01:46,240 --> 00:01:50,260
In this context you will come across
the term called dependency injection

24
00:01:50,260 --> 00:01:52,230
which we will talk about
in a little more detail.

25
00:01:55,100 --> 00:01:58,210
Going back to that
structure of our component,

26
00:01:58,210 --> 00:02:01,930
we see that now we have the component and
the template.

27
00:02:01,930 --> 00:02:05,300
So the template taking care
of rendering the view for

28
00:02:05,300 --> 00:02:09,540
our component and the component
itself managing the properties and

29
00:02:09,540 --> 00:02:14,880
the matrix that will be leverage by the
template for displaying the information.

30
00:02:14,880 --> 00:02:19,290
Now, the component itself can then
take the help of a service so

31
00:02:19,290 --> 00:02:25,350
in this case the service will be
injected into the component to provide

32
00:02:25,350 --> 00:02:30,050
certain features for
the component to make use of.

33
00:02:30,050 --> 00:02:33,230
So the service takes care
of doing all the work

34
00:02:33,230 --> 00:02:38,040
behind the scenes that facilitates
the component to be able to provide.

35
00:02:38,040 --> 00:02:39,970
Well the properties and the methods for

36
00:02:39,970 --> 00:02:43,390
the template to make use of
while rendering the view.

37
00:02:43,390 --> 00:02:47,930
And correspondingly,
transporting the user interaction

38
00:02:47,930 --> 00:02:52,290
related actions back to
the model behind the scenes.

39
00:02:53,580 --> 00:02:56,210
In the context of the service

40
00:02:56,210 --> 00:03:00,560
you'll often here people also
mentioning some related concepts.

41
00:03:00,560 --> 00:03:03,850
Things like dependency injection

42
00:03:03,850 --> 00:03:06,818
which we will talk about in
little more detail later.

43
00:03:06,818 --> 00:03:12,349
Then we'll also here
people tak about promises.

44
00:03:13,750 --> 00:03:18,060
We'll talk about promises
in the next module.

45
00:03:18,060 --> 00:03:19,900
I promise that.

46
00:03:19,900 --> 00:03:21,640
And finally, you'll also hear

47
00:03:23,610 --> 00:03:27,100
people talking about the use
of reactive JavaScript.

48
00:03:27,100 --> 00:03:30,450
Now, when we use service as
a reactive JavaScript comes to or

49
00:03:30,450 --> 00:03:33,660
help in accomplishing certain things.

50
00:03:33,660 --> 00:03:38,050
So we'll also look at reactive
JavaScript in the context of angular

51
00:03:38,050 --> 00:03:40,530
in the next module.

52
00:03:40,530 --> 00:03:46,141
Now that we have some basic understanding
of services let's use them in our

53
00:03:46,141 --> 00:03:51,306
application and then get to know
services first hand by practicing,

54
00:03:51,306 --> 00:03:55,780
implementing some services for
our angle of application.

55
00:03:55,780 --> 00:04:02,299
[MUSIC]