Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,860 --> 00:00:05,700
Now that we have our directive generated I want to give you a very quick example and show you how we
2
00:00:05,700 --> 00:00:07,560
can kind of play around with the elements.
3
00:00:07,590 --> 00:00:13,110
Do we apply the directive to the we're going to rebuild a very classic example of directives that you
4
00:00:13,110 --> 00:00:18,400
see inside of like every angular tutorial ever including the official documentation.
5
00:00:18,450 --> 00:00:22,890
I want to very briefly we're going to change the class directive but very briefly we're going to make
6
00:00:22,890 --> 00:00:28,690
our class directive apply a background color to whatever element we apply the directive to.
7
00:00:28,800 --> 00:00:33,600
But this is just going to help us understand how we can actually access the elements that we apply the
8
00:00:33,600 --> 00:00:39,450
directive to and how we can change some properties on it to get started at the very top.
9
00:00:39,510 --> 00:00:48,100
I'm going to import something called Element ref and then on the constructor I'm going to write in private
10
00:00:49,150 --> 00:00:56,330
element is of type element ref like So what does this element thing listeners we add in this argument.
11
00:00:56,400 --> 00:01:01,690
Angela's going to make sure that whenever we create an instance of class directive a first argument
12
00:01:01,690 --> 00:01:07,090
to the constructor is going to be the element that we applied the directive to then the words this element
13
00:01:07,090 --> 00:01:13,720
right here is pretty much a direct reference to that Ally lie right there we can access this element
14
00:01:13,720 --> 00:01:19,230
property and start to mess around with some of the underlying properties on the actual HDL element.
15
00:01:19,240 --> 00:01:22,600
For example we can start to add in some different styling rules and whatnot.
16
00:01:22,660 --> 00:01:25,710
We can modify some classes on it all that kind of good stuff.
17
00:01:27,200 --> 00:01:32,920
So instead of doing a cuts lug I'm going to instead reference this dot element and here's the one gotcha
18
00:01:32,920 --> 00:01:34,120
here.
19
00:01:34,120 --> 00:01:38,650
This dot element is not the actual H T.M. element to actually get the HMO element.
20
00:01:38,650 --> 00:01:43,490
We have to access a little property inside of element called eighth element.
21
00:01:43,600 --> 00:01:47,650
This native element thing that is the actual each small element we care about.
22
00:01:47,710 --> 00:01:53,340
Keep in mind as you start to access that element then on there we can mess around with that element
23
00:01:53,340 --> 00:01:58,860
in any way that we would normally mess around with each team L from some javascript code for example
24
00:01:58,860 --> 00:02:06,150
we can set a style on there or something like that but to set a style you could say style dots background
25
00:02:06,660 --> 00:02:20,480
lowercase G background color is about orange except now by save this and flip back over I'll see it's
26
00:02:20,550 --> 00:02:22,050
really hard to see here.
27
00:02:22,770 --> 00:02:24,700
I'm going to zoom in really really far.
28
00:02:24,750 --> 00:02:26,650
You'll notice that Yeah right there.
29
00:02:26,670 --> 00:02:27,310
Look at that.
30
00:02:27,330 --> 00:02:28,240
Yeah that's orange.
31
00:02:28,240 --> 00:02:29,460
See that orange background color.
32
00:02:29,610 --> 00:02:34,140
Okay maybe that was a bad place to apply this directive though let's try applying that directive to
33
00:02:34,140 --> 00:02:37,790
instead the H or element that we're creating right there at the beach.
34
00:02:38,010 --> 00:02:40,800
So it is working it's just really hard to see that background.
35
00:02:40,830 --> 00:02:46,020
We're gonna go back over my template to remove app class from the ally and then go down to the H four
36
00:02:46,020 --> 00:02:53,950
down here and apply hub class there instead of look back over Yeah there we go now it's orange was orange
37
00:02:53,950 --> 00:02:56,860
before but now you can actually see that it's orange.
38
00:02:56,860 --> 00:02:57,120
OK.
39
00:02:57,160 --> 00:03:01,260
So that's how we just reach into some directive how we get access to the elements.
40
00:03:01,380 --> 00:03:03,700
Now we just mess around at the element in some fashion.
41
00:03:03,790 --> 00:03:08,650
Oh pretty basic pretty straightforward but obviously this is not super useful is if we want to apply
42
00:03:08,650 --> 00:03:13,630
a background color of wants to an element Well we're just going to use some CSX we're not gonna write
43
00:03:13,630 --> 00:03:19,200
a custom directed for that nonetheless at least we understand how to reach out and grab an element.
44
00:03:19,200 --> 00:03:20,360
Let's take another pause right here.
45
00:03:20,370 --> 00:03:24,570
When come back the next video we're gonna figure out how we can receive some arguments into our directive
46
00:03:24,630 --> 00:03:25,080
as well.
5234
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.