Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,710 --> 00:00:06,480
We just added in the energy for structural directive right here to iterate over every post inside of
2
00:00:06,480 --> 00:00:08,360
our posts array and this video.
3
00:00:08,370 --> 00:00:11,870
Like I said I just want to clarify one or two quick things about this.
4
00:00:11,880 --> 00:00:16,740
First off whatever we are iterating over right here is gonna be a direct reference to a property tied
5
00:00:16,740 --> 00:00:18,150
to our component class.
6
00:00:18,240 --> 00:00:20,420
But in this case we're inside of our app component.
7
00:00:20,430 --> 00:00:25,770
So right there I can place any reference to any property that I have defined inside of my app components
8
00:00:26,270 --> 00:00:31,820
that can be either a property like post right here or we can also refer to different methods as well.
9
00:00:31,830 --> 00:00:39,820
For example when I say let post a post I could also do of get post but we had a method to get posts
10
00:00:39,820 --> 00:00:44,320
like so if we had a method called get post that returned an array of objects you could call that right
11
00:00:44,320 --> 00:00:47,560
here and then iterate over every post that we get back.
12
00:00:47,560 --> 00:00:51,940
In this case we don't have a method called get posts we're going to instead iterate over that property
13
00:00:51,940 --> 00:00:53,270
called Post.
14
00:00:53,410 --> 00:00:57,400
Now the next thing I want to mention here is this is something that's gonna be You'll just a little
15
00:00:57,400 --> 00:01:03,670
bit awkward is how the energy for directive kind of gives you access to that post variable right there.
16
00:01:03,670 --> 00:01:08,500
In particular I want to point out how the syntax you see right here is kind of different than how a
17
00:01:08,500 --> 00:01:11,960
traditional form of loop works inside a javascript.
18
00:01:12,070 --> 00:01:13,810
Of course the syntax is very different.
19
00:01:13,810 --> 00:01:17,920
Let me just see what I mean I'm gonna open up a new file really quickly.
20
00:01:17,970 --> 00:01:19,820
You do not have to create a new file here.
21
00:01:19,830 --> 00:01:25,550
I just want to give you an example of a for of loop inside this new file.
22
00:01:25,680 --> 00:01:27,710
I'm going to create a post Reagan.
23
00:01:27,940 --> 00:01:37,060
I'll give the first one the title of the tree and then a title of snowy mountain and whatever else.
24
00:01:37,070 --> 00:01:42,450
Now if I wanted to iterate over this array of objects I could do so with normal javascript using a for
25
00:01:42,670 --> 00:01:47,130
loop and it would look like this it would be for that host of hosts.
26
00:01:47,150 --> 00:01:51,650
You'll notice that the content right there is just about identical while 100 percent identical to what
27
00:01:51,650 --> 00:01:54,590
we saw inside of the energy for DirecTV.
28
00:01:54,590 --> 00:02:00,110
Now what's really awkward here is that that gives us access to a host variable and we can only access
29
00:02:00,110 --> 00:02:05,330
that variable inside of these curly braces though inside the curly braces I could do something like
30
00:02:05,360 --> 00:02:08,210
console dot log post dot title miss right here.
31
00:02:08,210 --> 00:02:15,280
Hundred percent valid code but there's no form of a for loop in which I could add like after the left
32
00:02:15,310 --> 00:02:23,230
post a post or I could say something like I don't know poster like console log right there right outside
33
00:02:23,350 --> 00:02:24,330
of the curly braces.
34
00:02:24,340 --> 00:02:27,010
Right this is 100 percent invalid syntax.
35
00:02:27,010 --> 00:02:28,710
This is not a thing at all.
36
00:02:28,750 --> 00:02:33,070
We only get access to the post variable inside of those curly braces.
37
00:02:33,160 --> 00:02:38,410
And so this is very different than what we are seeing right here with the energy for DirecTV.
38
00:02:38,530 --> 00:02:43,720
If the energy for DirecTV worked in the same kind of style as a traditional four of lube then we would
39
00:02:43,750 --> 00:02:47,540
only be able to access that post variable like inside of that element.
40
00:02:47,590 --> 00:02:54,230
Like right here but that is not the case when we make use of energy for we get the post variable and
41
00:02:54,230 --> 00:02:57,310
we can refer to that variable on the same element.
42
00:02:57,320 --> 00:03:01,940
Like right here and right here and right here and so on that we are applying the energy for DirecTV
43
00:03:01,940 --> 00:03:02,640
too.
44
00:03:02,900 --> 00:03:07,370
Now I don't know about you but for me that just feels a little bit weird because the behavior is very
45
00:03:07,370 --> 00:03:12,320
different as we just discussed than a traditional four of loop begin with a terminal for a loop.
46
00:03:12,320 --> 00:03:18,740
We only access that iterator variable inside the curly braces and if that was the same thing with energy
47
00:03:18,740 --> 00:03:23,210
for that would mean that we can only access post inside this thing like right here.
48
00:03:23,210 --> 00:03:29,150
But again that is not the case we can access that iterator variable on the element that we are applying
49
00:03:29,150 --> 00:03:32,260
the energy for DirecTV to as well okay.
50
00:03:32,320 --> 00:03:36,730
So let's just two quick things I wanted to mention about the energy for DirecTV.
51
00:03:36,740 --> 00:03:41,360
Just some stuff to kind of clarify what's going on though now that we've got all this stuff put together.
52
00:03:41,360 --> 00:03:42,470
Let's take a pause right here.
53
00:03:42,470 --> 00:03:46,580
We're gonna come back the next video and there's one last quick thing on a fix up inside of application.
6002
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.