Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,150 --> 00:00:05,140
Our application now looks pretty good but there's one last thing I would like to take care of.
2
00:00:05,290 --> 00:00:09,370
If you recall the original mockup that we looked at we had said that when the application first loads
3
00:00:09,370 --> 00:00:13,870
up inside the browser we were not going to show that additional little form element at the very bottom
4
00:00:14,380 --> 00:00:19,180
was only after a user generated a password that we were gonna show some additional content down there
5
00:00:19,870 --> 00:00:21,350
right now inside of our application.
6
00:00:21,370 --> 00:00:23,920
That element is visible at all times.
7
00:00:23,920 --> 00:00:29,260
Let's figure out some way to kind of conditionally either show or hide this little label in the input
8
00:00:29,260 --> 00:00:34,390
inside of it based upon whether or not a user has generated a password to do so.
9
00:00:34,400 --> 00:00:40,130
We're going to use a feature of angular that we use inside of our templates called a structural directive
10
00:00:41,120 --> 00:00:45,080
let's first write out the structural directive inside of our template and get our application working
11
00:00:45,230 --> 00:00:49,230
and we'll discuss exactly what a structural directive is.
12
00:00:49,260 --> 00:00:54,320
All right I'm going to get started by going back over to my editor and once again finding my app component.
13
00:00:54,360 --> 00:00:57,490
Each team will file an inside there.
14
00:00:57,510 --> 00:01:04,560
I'll go down to the very bottom and find a div with class box listed right here and the label and input
15
00:01:04,560 --> 00:01:09,170
inside of it are what display this stuff down here at the very bottom.
16
00:01:09,210 --> 00:01:15,510
We want to add in a structural directive that is going to toggle whether or not this div gets displayed
17
00:01:15,810 --> 00:01:17,110
and everything inside of it.
18
00:01:17,840 --> 00:01:24,860
But to do so I'm going to find the div and inside of the opening div tag I'm gonna put in Star and G
19
00:01:24,950 --> 00:01:30,750
F equals password.
20
00:01:30,820 --> 00:01:36,420
Now let's say this go back over to our application and see what we get as soon as I flip back over.
21
00:01:36,430 --> 00:01:42,010
I now see that by default I don't have that little output element at the bottom but if I enter in a
22
00:01:42,010 --> 00:01:46,030
length and check with these checkboxes and then generate the password.
23
00:01:46,030 --> 00:01:52,510
Now that element is visible again the purpose of the energy if structural directive is to conditionally
24
00:01:52,630 --> 00:01:56,650
show or hide some element inside of our template.
25
00:01:56,650 --> 00:02:01,540
Let's get a better idea of what this whole directive thing is and then kind of evaluate the syntax we
26
00:02:01,540 --> 00:02:07,320
just use right there to actually create it though in the world of angular directives are little bits
27
00:02:07,410 --> 00:02:10,520
of additional syntax we use inside of our templates.
28
00:02:10,650 --> 00:02:14,880
There are technically three different types of directives but we're only going to discuss two of them
29
00:02:14,940 --> 00:02:15,830
right now.
30
00:02:16,570 --> 00:02:21,480
So the two that we're going to discuss right now are structural directives and attribute directives.
31
00:02:21,690 --> 00:02:23,670
We just used a structural directive.
32
00:02:23,790 --> 00:02:29,220
The purpose of a structural directive is to add or remove an HDL element but essentially a structural
33
00:02:29,220 --> 00:02:29,690
directive.
34
00:02:29,700 --> 00:02:34,170
You can think of as changing the structure of our template.
35
00:02:34,380 --> 00:02:37,950
The other type of directive that we use is an attribute directive.
36
00:02:38,100 --> 00:02:43,260
The goal of this is to change the properties of some H.M. element that it gets applied to.
37
00:02:43,260 --> 00:02:48,270
There are a couple of structural directives in attribute directives that are included with angular.
38
00:02:48,270 --> 00:02:54,570
So by just using angular you get a couple of each of these right out of the box but you and I as developers
39
00:02:54,660 --> 00:03:00,270
also have the ability to write our own custom structural directives in our own custom attribute directives
40
00:03:00,330 --> 00:03:01,440
as well.
41
00:03:01,440 --> 00:03:06,800
And that's something that we're going to do later on INSIDE THIS COURSE though we're not going to cover
42
00:03:06,800 --> 00:03:08,450
Achebe directives too much just yet.
43
00:03:08,450 --> 00:03:12,920
All you really need to know is that we can use them to change the properties of an ancient element.
44
00:03:12,920 --> 00:03:16,910
And like I said we're going cover them a little bit more later on right now.
45
00:03:16,940 --> 00:03:21,650
Let's go back over to our editor and learn a little bit more about how the energy if structural DirecTV
46
00:03:21,680 --> 00:03:23,790
behaves.
47
00:03:23,830 --> 00:03:24,060
All right.
48
00:03:24,070 --> 00:03:26,760
So back over here as you can guess.
49
00:03:26,800 --> 00:03:32,680
This is the total key as we've seen with property binding and event binding already everything inside
50
00:03:32,680 --> 00:03:38,310
of the double quotes of the energy if structural DirecTV gets evaluated as code.
51
00:03:38,600 --> 00:03:44,120
So this right here riding up password means go over to our component class instance.
52
00:03:44,260 --> 00:03:49,020
Remember that's the app component to yes file it means go over to this thing.
53
00:03:49,060 --> 00:03:56,000
Take a look at the password property on our component class if this is ballsy.
54
00:03:56,000 --> 00:04:01,700
This value is falsely or if it's true the either conditionally hide or show this div and everything
55
00:04:01,700 --> 00:04:02,620
inside of it.
56
00:04:03,690 --> 00:04:10,060
So when our component is first initialized and shows up inside the DOM the value of password is empty
57
00:04:10,060 --> 00:04:10,590
string.
58
00:04:10,630 --> 00:04:13,010
That's how that password property starts out.
59
00:04:13,180 --> 00:04:16,390
Empty string inside of javascript is evaluated as false.
60
00:04:16,390 --> 00:04:19,000
It is like the Boolean value false.
61
00:04:19,000 --> 00:04:23,470
In other words when our component first gets displayed you can imagine that looking at parser right
62
00:04:23,470 --> 00:04:29,830
there essentially turns into false which means I add this element and everything inside of it and at
63
00:04:29,830 --> 00:04:35,260
some point time the user generates a password and we update the value of that password property to some
64
00:04:35,260 --> 00:04:38,210
actual defined string no password.
65
00:04:38,220 --> 00:04:44,160
At that point time essentially comes whatever they're randomly generated password is a string with some
66
00:04:44,160 --> 00:04:50,850
characters inside of it is evaluated by JavaScript as being true or truth in nature but kind of turns
67
00:04:50,850 --> 00:04:58,660
into energy if is true that means show this element and everything inside OK.
68
00:04:58,880 --> 00:05:03,650
Again we've now seen these couple of different pieces of syntax like the event binding the property
69
00:05:03,650 --> 00:05:08,360
binding all that stuff and the common theme here is that everything inside of those double quotes gets
70
00:05:08,360 --> 00:05:14,580
evaluated as code and we have access to all the variables all the properties off of our component class.
71
00:05:14,620 --> 00:05:18,130
So this is yet another example of that.
72
00:05:18,140 --> 00:05:18,410
All right.
73
00:05:18,440 --> 00:05:23,660
So as I mentioned we have the ability to write out our own structural directives and achieve directives
74
00:05:23,720 --> 00:05:26,560
and that is something we're going to take care of later on.
75
00:05:26,760 --> 00:05:29,010
I think our application looks pretty good.
76
00:05:29,010 --> 00:05:33,660
And I've said several times that there is just one or two more things to do on our application but there
77
00:05:33,660 --> 00:05:38,880
really is just one last very small thing we're going to take care of so quick pause and one last thing
78
00:05:38,940 --> 00:05:40,440
they're going to deal with around our app.
8746
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.