Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,020 --> 00:00:05,520
Our application is definitely working to some degree because we are showing both components on the screen
2
00:00:05,730 --> 00:00:07,580
but there is one little issue right now.
3
00:00:07,740 --> 00:00:12,410
Remember we only want to show one little page of sorts to the user at a time.
4
00:00:12,450 --> 00:00:17,430
I want to show either this elements home component that will eventually contain this segment thing and
5
00:00:17,430 --> 00:00:23,210
this place holder thing and then separately I want to at some other point time show this components
6
00:00:23,270 --> 00:00:29,180
home components and I want to decide whether to show one component or the other based upon the current
7
00:00:29,260 --> 00:00:32,420
U.R.L. that the user goes to slash elements.
8
00:00:32,420 --> 00:00:37,070
I want to show the elements home component if the user goes to slash collections.
9
00:00:37,130 --> 00:00:39,800
I want to show the collection some components.
10
00:00:39,800 --> 00:00:44,270
So let's figure out exactly how to show one component or another based upon the current.
11
00:00:44,270 --> 00:00:49,510
You are El the first thing I want to do is tell you about the current scenario that we are in.
12
00:00:49,550 --> 00:00:51,280
This is what we currently have.
13
00:00:51,280 --> 00:00:55,660
We've got our app module we've got the elements module we are exporting that elements home component
14
00:00:55,690 --> 00:01:00,220
and then making use of it at all times inside of our app component.
15
00:01:00,250 --> 00:01:06,070
Right now we would say that the elements module is a domain module because it is exporting this one
16
00:01:06,070 --> 00:01:12,130
component and that component is displayed at all times inside of the app component.
17
00:01:12,150 --> 00:01:17,080
We don't want to have a domain module instead remember we've got these different module types but we
18
00:01:17,080 --> 00:01:25,090
want to have is both a rounded module and a routine module a domain module is one where we have some
19
00:01:25,090 --> 00:01:28,340
components that are going to be displayed at all times.
20
00:01:28,630 --> 00:01:34,150
We want to have first a routed module because we want to have a component that is only going to be displayed
21
00:01:34,210 --> 00:01:40,840
at some point in time and we want to also have a routing module and that's going to define exactly when
22
00:01:40,840 --> 00:01:42,750
to show that component.
23
00:01:42,820 --> 00:01:49,150
Now just between you and me there really is not much difference between a routed module and a domain
24
00:01:49,150 --> 00:01:50,140
module.
25
00:01:50,150 --> 00:01:55,880
We're about to do a refactor and we're going to turn our elements module from a domain into a routed
26
00:01:56,170 --> 00:02:01,540
and here's the little like here's a little behind the scenes thing we're not really going to make any
27
00:02:01,540 --> 00:02:05,880
big change whatsoever to our elements module whatsoever.
28
00:02:05,890 --> 00:02:10,270
The only real thing we're gonna do here is add in a little bit of configuration to our routing module
29
00:02:10,330 --> 00:02:18,190
and say anytime that a user goes to a root of slash elements we want to show the elements home component.
30
00:02:18,670 --> 00:02:24,770
So here's what we are going to do all we're going to do is make sure that inside of our elements routing
31
00:02:24,770 --> 00:02:30,620
module missing was automatically created for us when we generated this elements module that is the elements
32
00:02:30,680 --> 00:02:36,110
routing module file right there the inside of that file we're going to add in a little bit of configuration
33
00:02:36,270 --> 00:02:42,440
we're gonna say anytime that someone goes to a root of elements we want to show the elements home component
34
00:02:42,500 --> 00:02:45,230
on the screen that's it that's all we have to do.
35
00:02:45,290 --> 00:02:52,170
Let me show you exactly how we do that we get started I mean first go back to my app component HMO file
36
00:02:52,630 --> 00:02:57,210
and I'm going to delete those two components that we're currently displaying I don't want to show them
37
00:02:57,240 --> 00:02:58,190
at all times.
38
00:02:58,230 --> 00:03:04,700
Instead I want to only show them when a user is at inappropriate root Next up inside of my elements
39
00:03:04,700 --> 00:03:11,120
module I no longer need to export my elements home component from here I'm going to remove it from that
40
00:03:11,120 --> 00:03:18,780
list of exports I'm not importing it into the app module anymore and then finally inside my elements
41
00:03:18,840 --> 00:03:23,730
routing module This is the real meat and potatoes this is the thing that actually matters inside the
42
00:03:23,820 --> 00:03:29,630
elements routing module we're going to setup a routing rule this is where we are going to say whenever
43
00:03:29,640 --> 00:03:36,330
user goes to a route of elements you want to show the elements home component but to do so at the top
44
00:03:36,360 --> 00:03:42,810
of my elements routing module file I'm going to import the component we want to display which is the
45
00:03:42,810 --> 00:03:51,830
elements home component from elements home elements home dot components and then inside of this routes
46
00:03:51,920 --> 00:04:01,340
array I'm going to add in one object and to that object I'll add in a path of elements and a component
47
00:04:01,430 --> 00:04:07,360
of elements home component like so as you add guests.
48
00:04:07,360 --> 00:04:10,510
This is saying anytime a user goes to the root elements.
49
00:04:10,690 --> 00:04:12,220
Joe this component on the screen.
50
00:04:13,490 --> 00:04:19,100
We are now in this kind of scenario important thing to understand here is that we don't really have
51
00:04:19,160 --> 00:04:24,440
a very direct tie between this component specifically and the app module.
52
00:04:24,470 --> 00:04:29,350
So at no point time right now does the app module actually reference the elements home component.
53
00:04:29,510 --> 00:04:36,020
Instead the app module just imports the entire elements home module and when it imports that entire
54
00:04:36,020 --> 00:04:41,210
module it also automatically is going to load up all these different routing rules who have defined
55
00:04:41,240 --> 00:04:44,350
inside of the elements routing module okay.
56
00:04:44,390 --> 00:04:47,350
So going to save this I can save all the files we just changed.
57
00:04:47,440 --> 00:04:50,560
I'll then go back over to my application now I will see it.
58
00:04:50,560 --> 00:04:56,740
Nothing on the screen but if I go to my address bar and navigate to a local host forty two hundred slash
59
00:04:57,280 --> 00:05:06,400
elements all DNC elements homeworks up here awesome if I go to any other root like elements slash or
60
00:05:06,550 --> 00:05:12,220
blah blah blah whatever else I'm going to very quickly see an error message inside my console that says
61
00:05:12,220 --> 00:05:16,240
sorry but we couldn't find any components to display based upon that root.
62
00:05:16,510 --> 00:05:21,080
Right now I can only go to lash elements.
63
00:05:21,250 --> 00:05:21,550
All right.
64
00:05:21,640 --> 00:05:24,010
So now we've got this put together with Paul's right here.
65
00:05:24,070 --> 00:05:25,300
Continue in just a moment.
7732
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.