Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,960 --> 00:00:04,950
We are now one step closer to re implementing the energy class directive.
2
00:00:05,040 --> 00:00:07,570
There's just one last little trick I want to show you.
3
00:00:07,620 --> 00:00:11,730
We've made use of several directives coming from angular already and you might notice that whenever
4
00:00:11,730 --> 00:00:15,110
we made use them we never had to write out like the name of a directive.
5
00:00:15,270 --> 00:00:20,550
And then separately like the name of some property I'm gonna show you a little trick here rather than
6
00:00:20,550 --> 00:00:24,600
having a at class directive and a background color property.
7
00:00:24,630 --> 00:00:29,730
You can instead change the name of the property that we are setting on our directive rather than saying
8
00:00:29,730 --> 00:00:31,650
that we're going to set background color right here.
9
00:00:31,650 --> 00:00:37,890
We can change that to say app class and back inside of our template.
10
00:00:37,960 --> 00:00:44,710
I'm going to change background color to app less and now because the selector or the way that we specify
11
00:00:44,710 --> 00:00:47,350
the directive and the property name are identical.
12
00:00:47,350 --> 00:00:53,860
We can technically remove the first app class this right here really does two different things for us.
13
00:00:53,860 --> 00:00:58,390
It says that we want to apply the app class directive to this element that's also going to attempt to
14
00:00:58,390 --> 00:01:06,540
set the app class property on the directive we can now save this and we'll get the exact same behavior
15
00:01:06,570 --> 00:01:07,470
as what we had before
16
00:01:10,420 --> 00:01:10,690
OK.
17
00:01:10,740 --> 00:01:12,670
So pretty simple pretty straightforward.
18
00:01:12,720 --> 00:01:14,120
Now one last thing on it mentioned here.
19
00:01:14,130 --> 00:01:18,360
Just because this is covered very thoroughly in the official documentation you're going to see at the
20
00:01:18,360 --> 00:01:23,400
official documentation says that putting a property on the cut on the actual class called app class
21
00:01:23,430 --> 00:01:28,560
is really confusing because when you read this right here and you see app class as a developer you might
22
00:01:28,560 --> 00:01:31,670
be looking at that and saying like wait a minute what does this method do.
23
00:01:31,680 --> 00:01:33,350
Why is it called app class.
24
00:01:33,410 --> 00:01:37,610
A very commonly it would be really nice if we could change the name this method to something else.
25
00:01:37,700 --> 00:01:43,330
It makes a little bit more sense done other words if I could leave this as like background color.
26
00:01:43,410 --> 00:01:47,340
That would be great because then I could read this as saying oh we're trying to like set the background
27
00:01:47,340 --> 00:01:48,080
color.
28
00:01:48,090 --> 00:01:49,860
Yeah sure that makes sense.
29
00:01:49,860 --> 00:01:53,790
But if we make that change then we can not tried to use app class back over here.
30
00:01:53,790 --> 00:02:01,570
We would have to go back to having separate app class and background color but to fix this we can use
31
00:02:01,630 --> 00:02:07,600
a little feature of the input decorator though on the input decorator we can provide a string that is
32
00:02:07,600 --> 00:02:12,910
going to be the name of the property that we are trying to set from the outside world.
33
00:02:12,910 --> 00:02:18,310
In other words we are trying to set the app class property inside of this input decorator we can put
34
00:02:18,310 --> 00:02:20,390
in app class.
35
00:02:20,560 --> 00:02:26,290
Now whenever we try to set the app class property is input decorator is going to kind of redirect that
36
00:02:26,530 --> 00:02:29,100
to the background color method.
37
00:02:29,100 --> 00:02:31,210
But from the outside world we are setting up class.
38
00:02:31,210 --> 00:02:33,060
That's what everyone in the outside world thinks.
39
00:02:33,100 --> 00:02:39,250
But inside of our actual class what actually gets executed is the background color method.
40
00:02:39,260 --> 00:02:41,840
Now we can save all these changes with makeover.
41
00:02:41,990 --> 00:02:44,860
Yep still works OK.
42
00:02:44,890 --> 00:02:49,640
So we've now got everything we need to know about making a custom energy class directive.
43
00:02:49,660 --> 00:02:50,790
Let's take a quick pause right here.
44
00:02:50,790 --> 00:02:51,940
We'll come back the next video.
45
00:02:51,940 --> 00:02:55,570
We're gonna make a couple of quick changes to this thing to finish off this directive.
46
00:02:55,580 --> 00:02:57,670
Now we're gonna take a look at structural directives.
4931
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.