Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,990 --> 00:00:05,340
Now that we've got that little reminder on how the energy if directive works let's try to apply it to
2
00:00:05,340 --> 00:00:10,110
our big list of allies that we're generating right here and just limit the number that we can see at
3
00:00:10,140 --> 00:00:11,210
any given time.
4
00:00:11,460 --> 00:00:16,470
A very easy way to use the energy of directive in this case just to kind of things kind of like working
5
00:00:16,470 --> 00:00:16,980
here.
6
00:00:16,980 --> 00:00:23,390
We could check the index or that I variable we can say that if i is less than five let's show the element.
7
00:00:23,400 --> 00:00:25,390
So we should use energy if true.
8
00:00:25,440 --> 00:00:28,150
Otherwise if the eye variable is greater than five.
9
00:00:28,160 --> 00:00:33,360
So like anything over here to the right hand side like all these things over here let's set the energy
10
00:00:33,390 --> 00:00:38,280
if two false so we can just try to hide all the things over here that's not going to be a very good
11
00:00:38,280 --> 00:00:39,210
long term solution.
12
00:00:39,390 --> 00:00:44,060
But it's at least going to expose you to a little air that's going to come up very quickly.
13
00:00:44,250 --> 00:00:44,490
OK.
14
00:00:44,520 --> 00:00:50,460
So I got to find that ally and then right after the energy for DirecTV I want to conditionally hide
15
00:00:50,460 --> 00:00:54,300
or show that L.A. element after it has been created by NRG for.
16
00:00:54,380 --> 00:00:58,740
I'll say energy if inside there I'll say I less than five.
17
00:00:58,920 --> 00:01:01,770
You'll notice right away I get a little air.
18
00:01:01,770 --> 00:01:04,010
Let's hover over that and see what the air is.
19
00:01:04,110 --> 00:01:09,010
The first sentence here is basically worthless and really doesn't tell us a lot about what's going on.
20
00:01:09,120 --> 00:01:16,780
What's more useful is the second statement says use only one attribute prefixed with Star and g the
21
00:01:16,780 --> 00:01:20,250
start N G is a reference to a structural directive.
22
00:01:20,350 --> 00:01:24,670
Remember a structural directive is a directive that changes the structure of our HCM out.
23
00:01:24,940 --> 00:01:32,980
It creates or removes HDMI elements both energy for an energy if are structural directives it turns
24
00:01:32,980 --> 00:01:39,040
out there's a very important rule for you to understand we can only apply one structural directive to
25
00:01:39,040 --> 00:01:44,890
any given element though this ally right now already has a structural directive we can not add a second
26
00:01:44,890 --> 00:01:51,450
one if we do we're gonna get an error that looks like that right there but how can we fix this we still
27
00:01:51,450 --> 00:01:57,030
want to produce a list of allies but we want to toggle whether or not some of these allies are visible
28
00:01:57,870 --> 00:02:03,450
maybe one way to handle this would be to wrap this ally with another element like a div or something
29
00:02:03,450 --> 00:02:10,890
like that let's try that out I'm going to wrap that Beghal ally with a div now we have two separate
30
00:02:10,890 --> 00:02:18,210
elements and now on the div I can apply the energy or directive to a div I'll cut the energy for DirecTV
31
00:02:18,360 --> 00:02:25,300
and paste it on the div now we're going to produce many copies of this div and everything inside of
32
00:02:25,300 --> 00:02:31,180
it and then for every single ally we'll take a look at the index if it's less than 5 we're going to
33
00:02:31,180 --> 00:02:36,700
show this element otherwise it's greater than 5 we're going to hide it so let's try this and see if
34
00:02:36,700 --> 00:02:42,460
it works out it's all flip back over and now I only see a couple of elements here let's definitely good
35
00:02:43,220 --> 00:02:49,150
but there's another issue notice how the styling of each individual Button has now changed a little
36
00:02:49,150 --> 00:02:54,700
bit each individual button is now kind of like it's own little segment whereas before they were kind
37
00:02:54,700 --> 00:02:59,950
of like this neat very join line and there was a solid line at the very bottom and now I see these rounded
38
00:02:59,950 --> 00:03:04,080
edges which just looks a little bit off though what's going on here.
39
00:03:04,800 --> 00:03:09,150
Well it turns out that just introducing additional elements into our template for the sake of using
40
00:03:09,150 --> 00:03:12,600
structural directives is generally a pretty bad idea.
41
00:03:12,630 --> 00:03:20,000
The reason for that is well what we just saw the bootstraps the SS library expects to see a well element
42
00:03:20,420 --> 00:03:26,330
with some allies directly inside of it but right now we don't have that we've got a UL that contains
43
00:03:26,330 --> 00:03:32,300
a div that contains the ally and so the styling that is being provided to us from bootstrap is not working
44
00:03:32,390 --> 00:03:38,130
as expected this is all because we just arbitrarily decided to throw an extra H simple element inside
45
00:03:38,130 --> 00:03:43,480
of the structure any time that you feel like you're going to use a structural directive like what we're
46
00:03:43,480 --> 00:03:48,980
doing right here just for the sake of adding in some like additional elements just we can throw on the
47
00:03:49,000 --> 00:03:54,880
additional structural directive it's generally a bad idea we don't want to add an arbitrary extra elements
48
00:03:55,810 --> 00:04:00,970
nonetheless we still want to use energy for and energy F and they can't be on the same element we're
49
00:04:00,970 --> 00:04:06,130
kind of back in the original scenario how are we gonna fix this now that have done a long enough lead
50
00:04:06,130 --> 00:04:08,300
in and I hope you understand what the problem is.
51
00:04:08,320 --> 00:04:12,910
Let me show you what the solution is rather than displaying an element of div right here we're going
52
00:04:12,910 --> 00:04:18,910
to instead show something called energy container I'm going to close the closing date right there or
53
00:04:18,910 --> 00:04:25,480
update the closing div two energy container as well an energy container is a very special element it
54
00:04:25,590 --> 00:04:31,720
doesn't actually create an HDMI element it exists solely so we can apply extra structural directives
55
00:04:31,810 --> 00:04:37,030
like this one right here energy container was made specifically to address the scenario that we are
56
00:04:37,030 --> 00:04:41,740
currently in this template actually gets rendered angular is going to take a look it's going to see
57
00:04:41,740 --> 00:04:46,420
this extra element right here it's going to process the energy for DirecTV but it's not going to display
58
00:04:46,420 --> 00:04:50,710
anything or energy container instead it's just going to take whatever its contents are.
59
00:04:50,710 --> 00:04:55,600
So in this case the ally and that is what is going to actually show up inside of our template.
60
00:04:55,600 --> 00:05:01,690
Again you can really imagine energy container as being like an invisible element of sorts if I now save
61
00:05:01,700 --> 00:05:08,090
this and flip back over now I've got the nice styling that I had before if I even open up my element
62
00:05:08,090 --> 00:05:16,810
inspector and take a look at the structure right there I'll see very quickly and I've got the Well I've
63
00:05:16,810 --> 00:05:19,140
got the previous page ally.
64
00:05:19,240 --> 00:05:24,130
Then I start up my list of allies right here that are being generated by the energy for it so I don't
65
00:05:24,130 --> 00:05:26,920
see any kind of like energy container or anything like that.
66
00:05:26,920 --> 00:05:29,300
I just see the ally again.
67
00:05:29,500 --> 00:05:33,010
That energy container element is like an invisible element.
68
00:05:33,010 --> 00:05:39,480
We use it specifically to get around that rule of only one structural directive per element.
69
00:05:39,520 --> 00:05:45,400
So this is a good improvement but right now our energy if logic right here is not that great just to
70
00:05:45,400 --> 00:05:47,440
in comparison to see if ice less than five.
71
00:05:47,590 --> 00:05:52,360
So that means if we start going to the left we're never gonna show any additional pages on the page
72
00:05:52,360 --> 00:05:53,060
nature.
73
00:05:53,170 --> 00:05:56,070
We need to have a little bit better logic inside there.
74
00:05:56,080 --> 00:06:02,500
Let's take a look at how we might fix that up rather than just checking to see if I is less than five.
75
00:06:02,500 --> 00:06:05,350
We're going to instead just do a little bit more of a check here.
76
00:06:05,350 --> 00:06:14,400
I'm going to call a method that I can define on our class called Jack vote check index check window
77
00:06:14,430 --> 00:06:20,330
index and I'll pass in I into their as you can guess.
78
00:06:20,330 --> 00:06:22,060
I really do have a good name for this method.
79
00:06:22,100 --> 00:06:26,180
I've a different name in my notes but I look at my notes right now I don't like the name I picked.
80
00:06:26,180 --> 00:06:30,650
So is going to use something arbitrarily different instead let's go defined that method back in our
81
00:06:30,650 --> 00:06:36,590
class and we're going to use that method to decide whether or not we should show this Ally go back inside
82
00:06:36,600 --> 00:06:37,580
my component.
83
00:06:37,620 --> 00:06:45,230
I'm gonna go down to the very bottom I'll define that method of check window index that will be called
84
00:06:45,230 --> 00:06:53,490
with some index that's going to be a number and from this I'm going to return math dot absolutes and
85
00:06:53,520 --> 00:06:59,350
we're going to find the difference between this dot current page and index.
86
00:06:59,430 --> 00:07:04,260
We're just gonna make sure that that is less than 5 very essentially going to show a window of five
87
00:07:04,320 --> 00:07:09,810
elements on either side of the current page and you might be curious why just to find an extra method
88
00:07:09,870 --> 00:07:13,060
just to essentially put down this little boolean statement.
89
00:07:13,200 --> 00:07:19,260
The reason is that we're making use of the math object right here and unfortunately we don't have access
90
00:07:19,260 --> 00:07:22,020
to the math object inside our template.
91
00:07:22,020 --> 00:07:27,450
Back over here inside the engine if I try to write out math dot absolutes we're going very quickly see
92
00:07:27,450 --> 00:07:30,620
an error and says sorry but you can't use that.
93
00:07:30,780 --> 00:07:34,070
That's the only reason I created the separate method.
94
00:07:34,110 --> 00:07:37,060
Now we have that separate method and we've got the energy if statement side there.
95
00:07:37,140 --> 00:07:38,670
Let's look back over.
96
00:07:38,670 --> 00:07:44,400
Now I see the first five elements and as I start to click next the window starts to expand and so it
97
00:07:44,400 --> 00:07:45,500
starts to grow.
98
00:07:45,570 --> 00:07:53,230
I can see now I've got all these different elements and then finally I start to get up to the end here.
99
00:07:53,350 --> 00:07:56,630
It's going to start to shrink down until I hit just 24.
100
00:07:56,630 --> 00:08:00,560
Now I think you can agree with me that having this like kind of expanding thing right here is really
101
00:08:00,590 --> 00:08:03,170
awkward particularly when you're starting to click next.
102
00:08:03,170 --> 00:08:08,120
As you keep on having to reposition the mouse and ideally we would figure out a better solution to this.
103
00:08:08,210 --> 00:08:10,940
But for right now honestly we're going to kind of ignore that.
104
00:08:10,940 --> 00:08:13,590
It's very much outside the purpose of this application.
105
00:08:13,620 --> 00:08:15,760
I'm not going to be too concerned about it.
106
00:08:15,800 --> 00:08:16,020
OK.
107
00:08:16,040 --> 00:08:18,640
So let's take a quick pause right here and continue in just a minute.
12642
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.