All language subtitles for 5. Importing and Exporting Modules

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,370 --> 00:00:05,120 Now that we have a couple of different modules inside our application let's figure out how to actually 2 00:00:05,120 --> 00:00:08,730 effectively use these modules in share code between them. 3 00:00:08,750 --> 00:00:13,100 The first thing we're going to do is generate a new component inside of our elements module. 4 00:00:13,100 --> 00:00:17,600 The goal of this component is to eventually show all the content you see right here. 5 00:00:17,600 --> 00:00:22,610 I want to show something says segment one show a segment component is right underneath that and then 6 00:00:22,610 --> 00:00:25,700 show a little place holder component inside there as well. 7 00:00:25,700 --> 00:00:27,120 That's what we're going to eventually do. 8 00:00:27,140 --> 00:00:33,490 But right now I just want to generate a component that's going to eventually show all this content when 9 00:00:33,490 --> 00:00:34,680 we generate this component. 10 00:00:34,690 --> 00:00:39,940 We're going to specifically create it inside of the elements module to do so we'll go back over to our 11 00:00:39,940 --> 00:00:47,190 command line and inside of our project directory we will once again run energy generate component. 12 00:00:47,590 --> 00:00:51,040 And now rather than just writing out the name of the component we're going to generate we're going to 13 00:00:51,040 --> 00:00:55,930 first write out the module that this should be placed in by want to generate something inside of my 14 00:00:56,050 --> 00:00:57,380 elements module. 15 00:00:57,480 --> 00:01:02,730 So I will write out elements slash and then the name of my component. 16 00:01:02,950 --> 00:01:08,110 In this case I'm going to call this component elements home because it's going to serve kind of as like 17 00:01:08,140 --> 00:01:15,860 the home screen of my elements feature I'm going to write out elements and I'll zoom out for just a 18 00:01:15,860 --> 00:01:19,630 second so you can see that entire command on one line okay. 19 00:01:19,680 --> 00:01:26,660 So I'll generate that I'm going to go backwards my code editor and take a look at what was created inside 20 00:01:26,660 --> 00:01:31,760 of my elements directory I'll now see it there is an elements home component there's the component right 21 00:01:31,760 --> 00:01:32,850 there. 22 00:01:33,100 --> 00:01:38,210 Now let's try to take this component and show it on the screen of our application to do so. 23 00:01:38,230 --> 00:01:43,780 Remember pretty simple process all we have to do is go to our app component and inside of our app component 24 00:01:43,840 --> 00:01:49,180 we're going to write out some little H2 mode looking tag that's going to try to show the elements home 25 00:01:49,180 --> 00:01:55,100 component on the screen to get started going to first once again select everything inside of my app 26 00:01:55,100 --> 00:01:59,440 component template except for all the way down at the bottom. 27 00:01:59,600 --> 00:02:04,570 And notice that there's now additional little tag right here called the router outlet. 28 00:02:04,580 --> 00:02:09,480 This was added in specifically because we generated our project with routing enabled. 29 00:02:09,560 --> 00:02:14,120 We're going to discuss exactly what this thing does in just a moment but first let's just delete all 30 00:02:14,120 --> 00:02:19,570 the other stuff inside of here then right above that router outlet thing. 31 00:02:19,580 --> 00:02:29,060 Let's try to show that elements home component by we'll write out app elements home like so right away. 32 00:02:29,120 --> 00:02:31,990 I'm seeing an error message start to appear inside my editor. 33 00:02:32,000 --> 00:02:34,850 If you do not see that error message that is totally okay. 34 00:02:35,090 --> 00:02:38,080 Let me tell you exactly what is going on here. 35 00:02:38,120 --> 00:02:44,740 So back over at this diagram just a moment ago we generated a new component inside of our elements module 36 00:02:45,190 --> 00:02:46,910 called it elements. 37 00:02:48,560 --> 00:02:54,080 Whenever we generate a component inside of a module no other module inside our application can get access 38 00:02:54,080 --> 00:02:56,050 to that component by default. 39 00:02:56,060 --> 00:03:02,120 Instead we have to form a specific link from the elements module to the app module. 40 00:03:02,120 --> 00:03:07,910 In other words we have to specifically say that we want to export this component from elements we essentially 41 00:03:07,910 --> 00:03:10,250 are saying hey this thing is open to the outside world. 42 00:03:10,250 --> 00:03:12,670 Anyone who wants it can come and get it. 43 00:03:12,980 --> 00:03:17,750 And then inside of our app module we have to write out some code that's going to go and reach out and 44 00:03:17,750 --> 00:03:21,800 grab that component and imported into the app module. 45 00:03:21,800 --> 00:03:23,810 So it is a two step process. 46 00:03:23,840 --> 00:03:29,350 You have to first export the component and then import it into the module where we want to get it. 47 00:03:29,360 --> 00:03:34,700 Remember just a little bit ago I mentioned very briefly that the module system inside of angular is 48 00:03:34,700 --> 00:03:40,510 similar to typescript files where we are creating variables classes functions of what non cyber file 49 00:03:40,820 --> 00:03:46,970 we can export that stuff from a file and then imported into another that whole system is very similar 50 00:03:46,970 --> 00:03:52,250 to the Angular module system we have to both export something and then import it something somewhere 51 00:03:52,250 --> 00:03:53,550 else. 52 00:03:53,550 --> 00:04:00,820 So let's first begin by exporting the elements home component from our elements module do so I'm gonna 53 00:04:00,840 --> 00:04:07,140 go and find my elements module file that is the elements dot module file inside the elements directory 54 00:04:08,620 --> 00:04:14,110 then inside of here right at the very bottom of this little energy module directive I'm going to write 55 00:04:14,110 --> 00:04:21,640 in a new property called exports all assign nothing an array and then inside of that array I'm going 56 00:04:21,640 --> 00:04:25,090 to write out our component which is the elements home component 57 00:04:28,840 --> 00:04:33,130 we have now exported the elements home component from the elements module. 58 00:04:33,130 --> 00:04:36,040 We've now said hey this thing is available to the outside world. 59 00:04:36,100 --> 00:04:38,690 Anyone who wants to make use this component can do so. 60 00:04:39,630 --> 00:04:46,350 Now step two we have to go into our app module and specifically import everything that is being exported 61 00:04:46,590 --> 00:04:54,600 from the elements module so I will now go over to my app module which is my adult module that TSA file 62 00:04:54,870 --> 00:04:56,480 inside of my app directly. 63 00:04:56,560 --> 00:05:05,230 It is right here and then inside of here I'm going to first write out an import statement and I'm going 64 00:05:05,230 --> 00:05:11,950 to get the elements module notice that I'm importing the module not specifically the components I can 65 00:05:11,950 --> 00:05:20,750 get the elements module from the elements directory and then elements dot module. 66 00:05:20,940 --> 00:05:26,130 And then finally I'm going to take elements module and add it inside of this decorators list of imports 67 00:05:26,400 --> 00:05:34,790 I'll put inside of here a comma and then elements module like so that this is the part where we're saying 68 00:05:34,790 --> 00:05:39,410 hey reach out to the elements module get access to all the components that have been exported from it 69 00:05:39,710 --> 00:05:45,980 and give us access to them inside of the app module if I now go back over to my app component each team 70 00:05:45,980 --> 00:05:50,870 I'll file where I had an error just a moment ago that error message is now gone. 71 00:05:51,020 --> 00:05:55,760 Let's now start up our development server we're going to make sure that we can see the app elements 72 00:05:55,760 --> 00:05:58,220 home component rendered on the screen. 73 00:05:58,520 --> 00:06:05,630 I'll go over to my terminal inside my project directory I'll do and serve and then after my development 74 00:06:05,630 --> 00:06:09,800 server starts up I'm going to navigate to a local host forty two hundred. 75 00:06:09,800 --> 00:06:12,190 As usual okay. 76 00:06:12,240 --> 00:06:12,830 That should be good. 77 00:06:12,820 --> 00:06:14,490 So local is forty two hundred. 78 00:06:14,610 --> 00:06:18,320 Now I can see elements homeworks on the screen okay. 79 00:06:18,350 --> 00:06:24,910 So I'd say that looks good again when we start to make components in the module system we have to specifically 80 00:06:25,030 --> 00:06:28,810 export a component that we want to make use of inside of another module. 81 00:06:28,930 --> 00:06:35,650 The Step one we export that thing up to we import the entire module into whatever other module wants 82 00:06:35,650 --> 00:06:37,630 to use that component. 83 00:06:37,650 --> 00:06:38,870 Let's take a quick pause right here. 84 00:06:38,880 --> 00:06:40,140 Continue in just a moment. 9657

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.