Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,120 --> 00:00:04,920
In this lecture, we're going to split our application into smaller pieces.
2
00:00:04,920 --> 00:00:09,030
At the top of the template, there's a link called Log and Register.
3
00:00:09,060 --> 00:00:12,570
The ultimate goal of this section is to make a modal appear.
4
00:00:12,570 --> 00:00:19,500
If the log in register link is clicked before we can handle toggling the modal, we'll need to organize
5
00:00:19,500 --> 00:00:20,670
our project.
6
00:00:20,700 --> 00:00:22,800
Switch over to our editor.
7
00:00:25,130 --> 00:00:31,130
Currently we have one active component which is the app component in the template block.
8
00:00:31,130 --> 00:00:33,600
We have the entire app inside of it.
9
00:00:33,620 --> 00:00:40,280
It's not necessary to house everything in one component because the state is available on a global level.
10
00:00:40,310 --> 00:00:44,720
Let's start moving things into their own components for a better management.
11
00:00:45,020 --> 00:00:49,130
We'll start with the header inside the components directory.
12
00:00:49,160 --> 00:00:52,670
Create a file called App Header View.
13
00:00:54,750 --> 00:00:57,420
Next, add the template block.
14
00:00:59,880 --> 00:01:03,990
Switching back to the app component search for the header section.
15
00:01:04,290 --> 00:01:07,110
It'll have a comment that says header above it.
16
00:01:09,530 --> 00:01:13,100
I've minimized the element so I wouldn't have to scroll.
17
00:01:13,130 --> 00:01:19,520
We're going to cut the NAV tag and its entire contents after you've grabbed the content, switched back
18
00:01:19,520 --> 00:01:24,170
to the header component and paste the contents into the template block.
19
00:01:26,590 --> 00:01:28,500
The header component is ready.
20
00:01:28,510 --> 00:01:30,520
The next step is to register it.
21
00:01:30,550 --> 00:01:32,770
We're going to register it locally.
22
00:01:32,770 --> 00:01:35,710
Site headers are generally used once.
23
00:01:35,710 --> 00:01:39,790
It's not something we'll need available for every component in our app.
24
00:01:39,790 --> 00:01:42,250
We won't register it globally.
25
00:01:42,640 --> 00:01:48,520
We'll register it in the app component, create the script block in the app component.
26
00:01:48,520 --> 00:01:52,450
If it isn't already there, we'll give it the name of app.
27
00:01:54,750 --> 00:01:57,330
Then import the header component.
28
00:01:57,330 --> 00:01:59,310
We'll call it app header.
29
00:02:01,730 --> 00:02:07,240
We're calling it EP header because there's already an HTML tag called header.
30
00:02:07,250 --> 00:02:11,760
We don't want to have naming conflicts with tags that already exist.
31
00:02:11,780 --> 00:02:17,690
An easy trick to prevent naming conflicts from happening is by pre fixing your components with a short
32
00:02:17,690 --> 00:02:19,130
phrase like app.
33
00:02:19,550 --> 00:02:23,770
Next, we'll add the components object to the app component.
34
00:02:23,780 --> 00:02:26,270
We'll register the app header component.
35
00:02:28,500 --> 00:02:30,880
This is ES6 syntax.
36
00:02:30,900 --> 00:02:34,020
This is the same as typing app header, app header.
37
00:02:34,050 --> 00:02:36,630
It's a nice shorthand way of doing things.
38
00:02:36,630 --> 00:02:42,930
Before we proceed, I want you to check out the Style Guide Link and the resource section of this lecture.
39
00:02:45,280 --> 00:02:47,310
I've shown you this page before.
40
00:02:47,320 --> 00:02:52,990
I'm linking to a specific function that states component names should be multi worded.
41
00:02:53,020 --> 00:02:59,500
This rule aims to help make sure your component names don't conflict with the names of existing HTML
42
00:02:59,500 --> 00:03:00,370
elements.
43
00:03:00,400 --> 00:03:04,060
It's a rule we're going to follow throughout the rest of this project.
44
00:03:04,330 --> 00:03:06,040
Let's go back to the editor.
45
00:03:06,070 --> 00:03:12,160
The last step is to use the component in the template scrolling back up and the component file will
46
00:03:12,160 --> 00:03:16,060
place the app header component where we previously removed it.
47
00:03:18,460 --> 00:03:21,740
Let's preview the application if you haven't already.
48
00:03:21,760 --> 00:03:22,990
Start the server.
49
00:03:23,050 --> 00:03:27,190
If everything worked, then you will see the page displaying normally.
50
00:03:27,220 --> 00:03:30,760
Just to make sure open the view developer tools.
51
00:03:30,760 --> 00:03:33,070
Search for the app header component.
52
00:03:33,100 --> 00:03:35,710
It will be listed under the app component.
53
00:03:38,350 --> 00:03:40,630
Our component is appearing in the list.
54
00:03:40,660 --> 00:03:42,890
It has been successfully imported.
55
00:03:42,910 --> 00:03:48,590
Let's work on moving the authentication model back inside the components directory.
56
00:03:48,610 --> 00:03:51,700
We'll create a file called Off View.
57
00:03:54,090 --> 00:03:58,530
Then scaffold the file with the template and script blocks.
58
00:04:00,670 --> 00:04:05,560
Will assign the name property in the exported object to auth.
59
00:04:07,790 --> 00:04:13,760
Next, go over to the app component file, scroll to the bottom of the template block.
60
00:04:13,790 --> 00:04:17,720
They will be a div tag with the ID of auth modal.
61
00:04:17,750 --> 00:04:21,560
It will have a comment above it saying authentication modal.
62
00:04:23,740 --> 00:04:26,410
Cut the entire element from the template.
63
00:04:28,610 --> 00:04:33,320
Subsequently we'll paste it into the auth components template block.
64
00:04:35,490 --> 00:04:36,900
The component is ready.
65
00:04:36,900 --> 00:04:41,400
Let's register it back inside the app components script block.
66
00:04:41,400 --> 00:04:45,220
We'll import the off component as app off.
67
00:04:47,810 --> 00:04:50,330
After importing it, we'll register it.
68
00:04:52,610 --> 00:04:56,030
The last step is to add the component in the location.
69
00:04:56,030 --> 00:04:56,960
We removed it.
70
00:04:56,990 --> 00:05:00,650
We'll load it at the bottom of the app components template.
71
00:05:02,940 --> 00:05:07,210
We've separated two sections of the app into separate components.
72
00:05:07,230 --> 00:05:10,140
There are more sections, but we'll get to them later.
73
00:05:10,170 --> 00:05:14,190
We want to focus on the elements that make up the authentication.
74
00:05:14,220 --> 00:05:20,550
We're finished with splitting the application into smaller pieces, and the next few lectures will start
75
00:05:20,550 --> 00:05:23,250
adding the logic for toggling the modal.
7026
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.