All language subtitles for 20. Context in Structural Directives

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
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
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,700 --> 00:00:06,020 As I just mentioned in this video we're going to attempt to replace the energy for DirecTV with the 2 00:00:06,020 --> 00:00:07,750 one that we just created. 3 00:00:07,770 --> 00:00:11,720 If you take a really close look at the energy for DirecTV that we currently have you'll notice that 4 00:00:11,720 --> 00:00:17,300 we are iterating over our list of images and we get access to that image variable but we never actually 5 00:00:17,330 --> 00:00:18,410 reference it. 6 00:00:18,470 --> 00:00:23,380 Nothing inside this energy for ever references that image variable. 7 00:00:23,390 --> 00:00:27,530 The only reason we're using energy for in general is really just to get access to the index. 8 00:00:27,530 --> 00:00:32,970 That's the only thing we really care about what we could do here is replace the entire energy floor 9 00:00:33,370 --> 00:00:34,760 with the app times directive. 10 00:00:34,760 --> 00:00:35,780 We just created. 11 00:00:35,840 --> 00:00:42,320 We can say we want to create a number of allies equal to however many images we have inside of our images 12 00:00:42,320 --> 00:00:43,290 array. 13 00:00:43,340 --> 00:00:48,160 Let me show you how we would do that going to first get started by deleting the entire energy for and 14 00:00:48,260 --> 00:00:53,930 I'll replace it with app times inside these double quotes. 15 00:00:53,950 --> 00:00:57,920 We're going to provide the number of times that we want to render out this ally. 16 00:00:58,030 --> 00:01:06,040 I want to show that ally a number of times equal to images that length this right here would work but 17 00:01:06,040 --> 00:01:07,820 there's just one little problem. 18 00:01:07,870 --> 00:01:11,110 You'll notice that inside of a lot of code we have inside of here or the markup. 19 00:01:11,110 --> 00:01:17,800 We've got references to our index right now with at times we don't actually have the ability to communicate 20 00:01:18,130 --> 00:01:22,150 which element or like what number of time we are iterating over. 21 00:01:22,480 --> 00:01:28,480 We can very easily add that by making one small change back inside of our directive back inside of my 22 00:01:28,480 --> 00:01:29,290 directive. 23 00:01:29,290 --> 00:01:36,050 Remember when we called Create embedded V right here we passed in an empty object as the second argument. 24 00:01:36,050 --> 00:01:39,590 This object right here is referred to as the context object. 25 00:01:39,760 --> 00:01:42,150 We can add in some different properties inside of here. 26 00:01:42,180 --> 00:01:47,680 It will make some different values accessible inside of our template through our directive. 27 00:01:47,680 --> 00:01:52,710 By far it is easiest to just see an example of this rather than have me give you a verbal description. 28 00:01:52,720 --> 00:01:56,590 So let me show you what we're going to do inside that context object. 29 00:01:56,620 --> 00:02:04,350 I'm going to add in a key value pair of index equal to I remember I is going to be the number that we 30 00:02:04,350 --> 00:02:05,750 are iterating over. 31 00:02:05,950 --> 00:02:09,520 So is going to start off a zero then one two three and so on. 32 00:02:09,520 --> 00:02:14,280 We're assigning that to a property of index when we pass in this context object. 33 00:02:14,340 --> 00:02:21,700 It's going to make all the properties on this object available for aliasing inside of our directive. 34 00:02:21,740 --> 00:02:24,970 You might recall what that aliasing aliasing thing really means. 35 00:02:24,980 --> 00:02:29,510 Just a moment ago when we had energy for we were already making use of aliasing right here. 36 00:02:30,070 --> 00:02:34,530 So when we make use of the energy for directive there are some variables that are exposed to us. 37 00:02:34,670 --> 00:02:38,630 But to actually get a hold of them we have to write out this little additional let statement like the 38 00:02:38,630 --> 00:02:44,440 one you see right there both the same thing as we start to try to get access to that context object 39 00:02:44,440 --> 00:02:51,270 we're going to write out our directive and images at length and a semicolon and then right after that 40 00:02:51,570 --> 00:02:59,370 we're gonna say let I equals and then the key or whatever property we want to assign to I from this 41 00:02:59,370 --> 00:03:00,770 context object. 42 00:03:00,840 --> 00:03:04,010 So in this case we want to assign a value coming from index. 43 00:03:04,040 --> 00:03:12,830 I'll say I equals index like so now I'm going to save this I'm going to flip back over and believe it 44 00:03:12,830 --> 00:03:14,030 or not hit still works. 45 00:03:14,030 --> 00:03:15,950 We still got our little patch Anita up here. 46 00:03:15,950 --> 00:03:19,510 Hundred percent equivalent behavior to what we had before. 47 00:03:19,600 --> 00:03:21,190 It's clear that this definitely works. 48 00:03:21,200 --> 00:03:27,470 But yeah like I said a little bit more confusing to create structural directives and attribute directives 49 00:03:28,210 --> 00:03:33,380 thus you know if we ever want to expose any other properties we can very easily add them into this context 50 00:03:33,380 --> 00:03:41,920 object by could for example say like color of red and then back inside I can set up another aliasing 51 00:03:41,920 --> 00:03:45,560 right here so I could say let c equals color. 52 00:03:45,840 --> 00:03:53,140 And now inside of here I can print out color excuse me not color but see I'll save that. 53 00:03:53,150 --> 00:03:59,000 What makeover and now we're going to see read all over the place Oh we probably don't want that's going 54 00:03:59,000 --> 00:03:59,850 to take that out. 55 00:03:59,960 --> 00:04:02,230 It's just a quick little example. 56 00:04:02,320 --> 00:04:06,600 I'm also going to move it back in the context object over here as well OK. 57 00:04:06,650 --> 00:04:11,690 So that is structural directives though as I've said like three times now at the end of a day I really 58 00:04:11,690 --> 00:04:16,430 expect that you're going to be creating custom attribute directives are more often than you create structural 59 00:04:16,430 --> 00:04:23,600 directives mutually also with you directives are so incredibly similar to components that a lot of times 60 00:04:23,660 --> 00:04:28,400 rather than creating a structural directive it might be easier to just create a separate component usually 61 00:04:28,400 --> 00:04:32,240 that ends up being a little bit easier and a little bit more clear to other engineers as well. 62 00:04:33,550 --> 00:04:33,820 OK. 63 00:04:33,850 --> 00:04:35,530 So that's pretty much it for directives. 64 00:04:35,530 --> 00:04:39,130 So we're going to pause right here and then move on to our next big topic in the next video. 7126

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