All language subtitles for 14. Building Lists with NgFor

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,130 --> 00:00:03,280 Well our application works pretty well right now. 2 00:00:03,290 --> 00:00:06,470 We see three different cards and each one has some different content. 3 00:00:06,650 --> 00:00:10,990 But right now the way our application is put together is just a little bit awkward. 4 00:00:11,000 --> 00:00:12,530 Let me show you what I mean. 5 00:00:12,590 --> 00:00:15,400 I'm gonna go back over to my app component class. 6 00:00:15,530 --> 00:00:17,100 Here's my app component. 7 00:00:17,240 --> 00:00:21,830 Inside there we've got that hosts array that are three different objects. 8 00:00:21,860 --> 00:00:27,140 Now I want to show you a little change I'm going to make to this file at the very bottom of the post 9 00:00:27,320 --> 00:00:28,520 array. 10 00:00:28,520 --> 00:00:31,820 I'm going to find that last object for mountain biking. 11 00:00:31,820 --> 00:00:37,340 I'm going to copy it and then duplicate it down to now inside of here if I zoom out really quickly you 12 00:00:37,340 --> 00:00:43,690 can see very easily that I have or separate objects though I would imagine that my application should 13 00:00:43,690 --> 00:00:48,800 now show or separate cards one for each post object inside of here. 14 00:00:49,030 --> 00:00:53,160 But if I go back over to my browser I still only see three cards. 15 00:00:53,210 --> 00:00:54,520 So why is that. 16 00:00:54,520 --> 00:01:00,930 Well right now our app component template is hardcoded so it only ever shows three card components. 17 00:01:01,150 --> 00:01:05,740 The first one is always going to read from the first element site posts and we've got the second and 18 00:01:05,740 --> 00:01:11,250 the third so when I say that our application is a little bit awkward right now it is awkward because 19 00:01:11,250 --> 00:01:16,770 if we start to add in more post objects our template is not going to update automatically and show those 20 00:01:16,800 --> 00:01:18,050 additional posts. 21 00:01:18,300 --> 00:01:23,430 Then this video we're going to take care of that we're going to make sure that for every post object 22 00:01:23,640 --> 00:01:29,100 inside of our posts array we show a separate instance of the card component automatically. 23 00:01:29,100 --> 00:01:32,100 So as that posts array right there grows or shrinks. 24 00:01:32,100 --> 00:01:35,730 We're going to get an equivalent number of card components created. 25 00:01:35,730 --> 00:01:37,600 Let me show you exactly how to do that. 26 00:01:37,650 --> 00:01:43,020 Now as a quick reminder before we write any code I want you to recall that in the last application we 27 00:01:43,020 --> 00:01:49,680 spoke about structural directives we said that structural directives are used to add or remove HDL elements. 28 00:01:49,870 --> 00:01:55,410 These structured directive that we used was n g f though in order to make sure that our app component 29 00:01:55,410 --> 00:02:00,150 template always shows the right number of card components we're going to use another structural directive 30 00:02:00,520 --> 00:02:08,160 or the energy or directive let's write out some code back inside of my app component not h small file. 31 00:02:08,380 --> 00:02:14,230 I'm going to delete everything inside of here and then I will replace it with one single instance of 32 00:02:14,290 --> 00:02:21,840 app dash card then on that element I can give myself a little bit of space and I'm going to apply the 33 00:02:21,840 --> 00:02:33,560 end G for directive to it was a star and G4 is going to be let post of those now on this element. 34 00:02:33,590 --> 00:02:40,120 We're going to produce a number of cards equal to however many posts we have as we iterate through all 35 00:02:40,120 --> 00:02:45,280 the posts inside that post array we're going to have access to a post variable inside of our template 36 00:02:45,640 --> 00:02:50,500 we can access inside of this element right here and we could access all the different properties of 37 00:02:50,500 --> 00:02:56,500 the post variable in the words the word post right here is like a reference to that post object and 38 00:02:56,500 --> 00:03:02,140 then that one and then that one and so on that we're going to take that post object we're going to take 39 00:03:02,170 --> 00:03:07,540 all the properties out of it and apply them to the card component in the same exact way that we are 40 00:03:07,540 --> 00:03:07,840 doing. 41 00:03:07,840 --> 00:03:13,800 Just a moment ago Now let's say title will come from post title. 42 00:03:13,920 --> 00:03:19,590 Notice now I don't have to put in any index inside of here because we are iterating over just one single 43 00:03:19,590 --> 00:03:20,440 object right now. 44 00:03:20,490 --> 00:03:29,700 So it's simply post dot title and we'll also do our image your URL which is post image well we've got 45 00:03:29,760 --> 00:03:33,950 our user name and our content 46 00:03:37,360 --> 00:03:37,720 all right. 47 00:03:37,720 --> 00:03:38,730 So let's save this. 48 00:03:38,740 --> 00:03:44,290 We're gonna go back over to our browser and now we'll see that we have a number of cards being automatically 49 00:03:44,290 --> 00:03:50,340 created equal to the number of post objects inside the posts array in particular at the very start of 50 00:03:50,340 --> 00:03:52,880 this video I duplicated that last object. 51 00:03:52,960 --> 00:03:59,790 Now down here at the bottom I see two copies of a mountain biking card in a row we can also say decrease 52 00:03:59,790 --> 00:04:05,540 the number of posts we have for example if I delete all the objects inside of here except for one. 53 00:04:05,760 --> 00:04:08,820 Now I've just got one post object if I save this file. 54 00:04:08,820 --> 00:04:14,430 Now I only see one card but using the energy for DirecTV is really useful. 55 00:04:14,500 --> 00:04:20,390 Anytime we need to iterate over an array of anything and show one component for every element inside 56 00:04:20,410 --> 00:04:25,480 that array there are one or two quick things I want you to understand about energy for let's take a 57 00:04:25,480 --> 00:04:29,710 quick pause come back the next video and I just want to clarify a couple of different things about it. 6515

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